Nir Soffer has uploaded a new change for review.
Change subject: procwatch: Port to python 3
......................................................................
procwatch: Port to python 3
Fix test_recv and test_write to work with python 3.
Change-Id: I2761035a9a503ca283568e530c7b83ec53d104b6
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/Makefile.am
M tests/procwatch_test.py
2 files changed, 5 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/65080/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7135718..faa1df4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -208,7 +208,6 @@
outOfProcessTests.py \
periodicTests.py \
persistentDictTests.py \
- procwatch_test.py \
properties_test.py \
protocoldetectorTests.py \
qemuimg_test.py \
diff --git a/tests/procwatch_test.py b/tests/procwatch_test.py
index c97e920..6dad27a 100644
--- a/tests/procwatch_test.py
+++ b/tests/procwatch_test.py
@@ -38,7 +38,7 @@
(['sh', '-c', 'echo -n "%s" >&2'],
False, True),
])
def test_receive(self, cmd, recv_out, recv_err):
- text = bytes('Hello World')
+ text = 'Hello World'
received = bytearray()
def recv_data(buffer):
@@ -60,14 +60,14 @@
retcode = process.wait()
self.assertEqual(retcode, 0)
- self.assertEqual(text, received)
+ self.assertEqual(text, received.decode('ascii'))
@permutations([
(['cat'], True, False),
(['sh', '-c', 'cat >&2'], False, True),
])
def test_write(self, cmd, recv_out, recv_err):
- text = bytes('Hello World')
+ data = b'Hello World'
received = bytearray()
def recv_data(buffer):
@@ -81,7 +81,7 @@
recv_data if recv_out else self.unexpected_data,
recv_data if recv_err else self.unexpected_data)
- process.stdin.write(text)
+ process.stdin.write(data)
process.stdin.flush()
process.stdin.close()
@@ -91,7 +91,7 @@
retcode = process.wait()
self.assertEqual(retcode, 0)
- self.assertEqual(text, str(received))
+ self.assertEqual(data, received)
def test_timeout(self):
process = self.start_process(["sleep", "5"])
--
To view, visit
https://gerrit.ovirt.org/65080
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2761035a9a503ca283568e530c7b83ec53d104b6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>