aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-05-07 10:42:23 +0200
committerCédric Ollivier <ollivier.cedric@gmail.com>2019-05-23 21:05:08 +0200
commit3eb87ae05f96cb9a687cac9b9d9c2b687a9ef302 (patch)
tree79191663807f7ad2c69845727042f59759307c52
parentad62290928a7c4b2851b2b3d575185d4337f0881 (diff)
Update to Python3
Now Xtesting containers use Python3 instead of python2. https://mail.python.org/pipermail/python-dev/2018-March/152348.html It also updates robotframework to latest release. Change-Id: I57e0d8b1af9aeaae0c445941a9bdf0b8bd346834 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 6f8aa2785e0239dbed22fcb4d093a5bc110bcc3c)
-rw-r--r--xtesting/core/feature.py6
-rw-r--r--xtesting/core/unit.py8
-rw-r--r--xtesting/tests/unit/core/test_unit.py6
3 files changed, 10 insertions, 10 deletions
diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py
index 2730179f..f28e720c 100644
--- a/xtesting/core/feature.py
+++ b/xtesting/core/feature.py
@@ -111,10 +111,10 @@ class BashFeature(Feature):
process = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- for line in iter(process.stdout.readline, ''):
+ for line in iter(process.stdout.readline, b''):
if console:
- sys.stdout.write(line)
- f_stdout.write(line)
+ sys.stdout.write(line.decode("utf-8"))
+ f_stdout.write(line.decode("utf-8"))
process.wait()
with open(self.result_file, 'r') as f_stdin:
self.__logger.debug("$ %s\n%s", cmd, f_stdin.read().rstrip())
diff --git a/xtesting/core/unit.py b/xtesting/core/unit.py
index f874d01f..774411a4 100644
--- a/xtesting/core/unit.py
+++ b/xtesting/core/unit.py
@@ -48,7 +48,7 @@ class Suite(testcase.TestCase):
stats = subprocess.Popen(
['subunit-stats'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
output, _ = stats.communicate(stream.read())
- cls.__logger.info("\n\n%s", output)
+ cls.__logger.info("\n\n%s", output.decode("utf-8"))
def generate_xunit(self, stream):
"""Generate junit report from subunit stream
@@ -62,7 +62,7 @@ class Suite(testcase.TestCase):
['subunit2junitxml'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
output, _ = stats.communicate(stream.read())
- xml.write(output)
+ xml.write(output.decode("utf-8"))
def generate_html(self, stream):
"""Generate html report from subunit stream
@@ -113,12 +113,12 @@ class Suite(testcase.TestCase):
self.start_time = time.time()
if not os.path.isdir(self.res_dir):
os.makedirs(self.res_dir)
- stream = six.StringIO()
+ stream = six.BytesIO()
result = SubunitTestRunner(
stream=stream, verbosity=2).run(self.suite).decorated
self.generate_stats(stream)
self.generate_xunit(stream)
- with open('{}/subunit_stream'.format(self.res_dir), 'w') as subfd:
+ with open('{}/subunit_stream'.format(self.res_dir), 'wb') as subfd:
stream.seek(0)
shutil.copyfileobj(stream, subfd)
self.generate_html('{}/subunit_stream'.format(self.res_dir))
diff --git a/xtesting/tests/unit/core/test_unit.py b/xtesting/tests/unit/core/test_unit.py
index 20fd6959..0af3ddca 100644
--- a/xtesting/tests/unit/core/test_unit.py
+++ b/xtesting/tests/unit/core/test_unit.py
@@ -59,7 +59,7 @@ class SuiteTesting(unittest.TestCase):
return_value=mock.Mock(
communicate=mock.Mock(return_value=("foo", "bar"))))
def test_generate_xunit_ok(self, *args):
- stream = six.StringIO()
+ stream = six.BytesIO()
with mock.patch('six.moves.builtins.open',
mock.mock_open()) as mock_open:
self.psrunner.generate_xunit(stream)
@@ -96,7 +96,7 @@ class SuiteTesting(unittest.TestCase):
with mock.patch('six.moves.builtins.open', mock.mock_open()) as m_open:
self.assertEqual(self.psrunner.run(), status)
m_open.assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir), 'w')
+ '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb')
self.assertEqual(self.psrunner.is_successful(), result)
args[0].assert_called_once_with(self.psrunner.suite)
args[1].assert_not_called()
@@ -115,7 +115,7 @@ class SuiteTesting(unittest.TestCase):
with mock.patch('six.moves.builtins.open', mock.mock_open()) as m_open:
self.assertEqual(self.psrunner.run(name=name), status)
m_open.assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir), 'w')
+ '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb')
self.assertEqual(self.psrunner.is_successful(), result)
args[0].assert_called_once_with(self.psrunner.suite)
args[1].assert_called_once_with()