summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/tests/helpers.py12
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source_v1.py3
2 files changed, 8 insertions, 7 deletions
diff --git a/cloudinit/tests/helpers.py b/cloudinit/tests/helpers.py
index 14c0b0bf..a2e10536 100644
--- a/cloudinit/tests/helpers.py
+++ b/cloudinit/tests/helpers.py
@@ -433,12 +433,12 @@ if not hasattr(mock.Mock, 'assert_not_called'):
mock.Mock.assert_not_called = __mock_assert_not_called
-# older unittest2.TestCase (centos6) do not have assertRaisesRegex
-# And setting assertRaisesRegex to assertRaisesRegexp causes
-# https://github.com/PyCQA/pylint/issues/1653 . So the workaround.
+# older unittest2.TestCase (centos6) have only the now-deprecated
+# assertRaisesRegexp. Simple assignment makes pylint complain, about
+# users of assertRaisesRegex so we use getattr to trick it.
+# https://github.com/PyCQA/pylint/issues/1946
if not hasattr(unittest2.TestCase, 'assertRaisesRegex'):
- def _tricky(*args, **kwargs):
- return unittest2.TestCase.assertRaisesRegexp
- unittest2.TestCase.assertRaisesRegex = _tricky
+ unittest2.TestCase.assertRaisesRegex = (
+ getattr(unittest2.TestCase, 'assertRaisesRegexp'))
# vi: ts=4 expandtab
diff --git a/tests/unittests/test_handler/test_handler_apt_source_v1.py b/tests/unittests/test_handler/test_handler_apt_source_v1.py
index 3a3f95ca..46ca4ce4 100644
--- a/tests/unittests/test_handler/test_handler_apt_source_v1.py
+++ b/tests/unittests/test_handler/test_handler_apt_source_v1.py
@@ -569,7 +569,8 @@ class TestAptSourceConfig(TestCase):
newcfg = cc_apt_configure.convert_to_v3_apt_format(cfg_3_only)
self.assertEqual(newcfg, cfg_3_only)
# collision (unequal)
- with self.assertRaises(ValueError):
+ match = "Old and New.*unequal.*apt_proxy"
+ with self.assertRaisesRegex(ValueError, match):
cc_apt_configure.convert_to_v3_apt_format(cfgconflict)
def test_convert_to_new_format_dict_collision(self):