summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-03-16 13:41:40 -0600
committerChad Smith <chad.smith@canonical.com>2018-03-16 13:41:40 -0600
commit95bb226921b8075ca9f65a9d2b672a3e342498b7 (patch)
tree89252056f297907d205f3caaaf302874279359de /tests/unittests/test_handler
parentb7b7331b9c308d8e1cb0b3dfd4398e6e7cb1b60f (diff)
downloadvyos-cloud-init-95bb226921b8075ca9f65a9d2b672a3e342498b7.tar.gz
vyos-cloud-init-95bb226921b8075ca9f65a9d2b672a3e342498b7.zip
tests: Make pylint happy and fix python2.6 uses of assertRaisesRegex.
Older unittest2.TestCase (as seen in CentOS 6) do not have an assertRaisesRegex method. They only have the now-deprecated assertRaisesRegexp. We need our unit tests to work there and on newer python (3.6). Simply making assertRaisesRegex = assertRaisesRegexp makes pylint complain as described in https://github.com/PyCQA/pylint/issues/1946 . What was here before this commit was actually broken. This commit makes assertRaisesRegex functional in CentOS 6 and works around the invalid Deprecated warning from pylint. To prove this, we use assertRaisesRegex in a unit test which will be exectued in py27, py3 and py26.
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source_v1.py3
1 files changed, 2 insertions, 1 deletions
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):