aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-05-12 13:33:24 +0200
committerCédric Ollivier <ollivier.cedric@gmail.com>2019-05-23 21:05:18 +0200
commit4f7433d65a774f5229e308d350bac392f8475523 (patch)
tree1a08fe8b0a658ad79703a1943cff1291f7cf2085
parent1c477fb1cc0a6203eb5fc22b0f99ad262d959215 (diff)
Fix unit tests (py36)
It completes the patch "Update to Python3" [1] which was not fully verified in Functest Gates [2]. [1] https://gerrit.opnfv.org/gerrit/#/c/67782/ [2] https://travis-ci.org/collivier/functest-xtesting/jobs/531380395 Change-Id: Icd0d743e14ca1430828907cefba10b50489020a5 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 934e90a269ea6b65e38578ac3f9a8bf7fc5212b1)
-rw-r--r--xtesting/tests/unit/core/test_feature.py20
-rw-r--r--xtesting/tests/unit/core/test_unit.py4
2 files changed, 12 insertions, 12 deletions
diff --git a/xtesting/tests/unit/core/test_feature.py b/xtesting/tests/unit/core/test_feature.py
index cbee8511..30678798 100644
--- a/xtesting/tests/unit/core/test_feature.py
+++ b/xtesting/tests/unit/core/test_feature.py
@@ -115,8 +115,8 @@ class BashFeatureTesting(FeatureTestingBase):
@mock.patch('os.path.isdir', return_value=True)
@mock.patch('subprocess.Popen')
def test_run_ko2(self, *args):
- stream = six.StringIO()
- stream.write("foo")
+ stream = six.BytesIO()
+ stream.write(b"foo")
stream.seek(0)
attrs = {'return_value.stdout': stream, 'return_value.returncode': 1}
args[0].configure_mock(**attrs)
@@ -131,8 +131,8 @@ class BashFeatureTesting(FeatureTestingBase):
@mock.patch('os.path.isdir', return_value=True)
@mock.patch('subprocess.Popen')
def test_run1(self, *args):
- stream = six.StringIO()
- stream.write("foo")
+ stream = six.BytesIO()
+ stream.write(b"foo")
stream.seek(0)
attrs = {'return_value.stdout': stream, 'return_value.returncode': 0}
args[0].configure_mock(**attrs)
@@ -147,8 +147,8 @@ class BashFeatureTesting(FeatureTestingBase):
@mock.patch('os.path.isdir', return_value=True)
@mock.patch('subprocess.Popen')
def test_run2(self, *args):
- stream = six.StringIO()
- stream.write("foo")
+ stream = six.BytesIO()
+ stream.write(b"foo")
stream.seek(0)
attrs = {'return_value.stdout': stream, 'return_value.returncode': 0}
args[0].configure_mock(**attrs)
@@ -163,8 +163,8 @@ class BashFeatureTesting(FeatureTestingBase):
@mock.patch('os.path.isdir', return_value=True)
@mock.patch('subprocess.Popen')
def test_run3(self, *args):
- stream = six.StringIO()
- stream.write("foo")
+ stream = six.BytesIO()
+ stream.write(b"foo")
stream.seek(0)
attrs = {'return_value.stdout': stream, 'return_value.returncode': 0}
args[0].configure_mock(**attrs)
@@ -180,8 +180,8 @@ class BashFeatureTesting(FeatureTestingBase):
@mock.patch('os.path.isdir', return_value=False)
@mock.patch('subprocess.Popen')
def test_run4(self, *args):
- stream = six.StringIO()
- stream.write("foo")
+ stream = six.BytesIO()
+ stream.write(b"foo")
stream.seek(0)
attrs = {'return_value.stdout': stream, 'return_value.returncode': 0}
args[0].configure_mock(**attrs)
diff --git a/xtesting/tests/unit/core/test_unit.py b/xtesting/tests/unit/core/test_unit.py
index 0af3ddca..3be41442 100644
--- a/xtesting/tests/unit/core/test_unit.py
+++ b/xtesting/tests/unit/core/test_unit.py
@@ -34,7 +34,7 @@ class SuiteTesting(unittest.TestCase):
@mock.patch('subprocess.Popen',
return_value=mock.Mock(
- communicate=mock.Mock(return_value=("foo", "bar"))))
+ communicate=mock.Mock(return_value=(b"foo", b"bar"))))
def test_generate_stats_ok(self, *args):
stream = six.StringIO()
self.psrunner.generate_stats(stream)
@@ -57,7 +57,7 @@ class SuiteTesting(unittest.TestCase):
@mock.patch('subprocess.Popen',
return_value=mock.Mock(
- communicate=mock.Mock(return_value=("foo", "bar"))))
+ communicate=mock.Mock(return_value=(b"foo", b"bar"))))
def test_generate_xunit_ok(self, *args):
stream = six.BytesIO()
with mock.patch('six.moves.builtins.open',