diff options
Diffstat (limited to 'functest/tests/unit')
-rw-r--r-- | functest/tests/unit/test_utils.py | 14 | ||||
-rw-r--r-- | functest/tests/unit/utils/test_openstack_clean.py | 2 | ||||
-rw-r--r-- | functest/tests/unit/utils/test_openstack_snapshot.py | 2 | ||||
-rw-r--r-- | functest/tests/unit/utils/test_openstack_utils.py | 5 |
4 files changed, 15 insertions, 8 deletions
diff --git a/functest/tests/unit/test_utils.py b/functest/tests/unit/test_utils.py index e171db02..15904764 100644 --- a/functest/tests/unit/test_utils.py +++ b/functest/tests/unit/test_utils.py @@ -8,16 +8,22 @@ import re -class RegexMatch(str): +class RegexMatch(object): + def __init__(self, msg): + self.msg = msg + def __eq__(self, other): - match = re.search(self, other) + match = re.search(self.msg, other) if match: return True return False -class SubstrMatch(str): +class SubstrMatch(object): + def __init__(self, msg): + self.msg = msg + def __eq__(self, other): - if self in other: + if self.msg in other: return True return False diff --git a/functest/tests/unit/utils/test_openstack_clean.py b/functest/tests/unit/utils/test_openstack_clean.py index 6ae7faa4..d85bd2ba 100644 --- a/functest/tests/unit/utils/test_openstack_clean.py +++ b/functest/tests/unit/utils/test_openstack_clean.py @@ -711,7 +711,7 @@ class OSCleanTesting(unittest.TestCase): as mock_remove_tenants, \ mock.patch('functest.utils.openstack_clean.yaml.safe_load', return_value=mock.Mock()), \ - mock.patch('__builtin__.open', mock.mock_open()) as m: + mock.patch('six.moves.builtins.open', mock.mock_open()) as m: openstack_clean.main() self.assertTrue(mock_remove_instances) self.assertTrue(mock_remove_images) diff --git a/functest/tests/unit/utils/test_openstack_snapshot.py b/functest/tests/unit/utils/test_openstack_snapshot.py index 33e74609..919b28c6 100644 --- a/functest/tests/unit/utils/test_openstack_snapshot.py +++ b/functest/tests/unit/utils/test_openstack_snapshot.py @@ -222,7 +222,7 @@ class OSSnapshotTesting(unittest.TestCase): return_value=self.update_list), \ mock.patch('functest.utils.openstack_snapshot.get_tenants', return_value=self.update_list), \ - mock.patch('__builtin__.open', mock.mock_open()) as m: + mock.patch('six.moves.builtins.open', mock.mock_open()) as m: openstack_snapshot.main() mock_logger_info.assert_called_once_with("Generating OpenStack " "snapshot...") diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py index 307cbe37..01085bb7 100644 --- a/functest/tests/unit/utils/test_openstack_utils.py +++ b/functest/tests/unit/utils/test_openstack_utils.py @@ -365,7 +365,8 @@ class OSUtilsTesting(unittest.TestCase): except: pass f = 'rc_file' - with mock.patch('__builtin__.open', mock.mock_open(read_data=msg), + with mock.patch('six.moves.builtins.open', + mock.mock_open(read_data=msg), create=True) as m: m.return_value.__iter__ = lambda self: iter(self.readline, '') openstack_utils.source_credentials(f) @@ -1460,7 +1461,7 @@ class OSUtilsTesting(unittest.TestCase): return_value=True), \ mock.patch('functest.utils.openstack_utils.get_image_id', return_value=''), \ - mock.patch('__builtin__.open', + mock.patch('six.moves.builtins.open', mock.mock_open(read_data='1')) as m: self.assertEqual(openstack_utils. create_glance_image(self.glance_client, |