From 2c1ca1e5c1e0365f3d5bf4cb2b7b021d922f47b4 Mon Sep 17 00:00:00 2001 From: Sebastien Awwad Date: Thu, 28 Mar 2019 18:46:17 -0400 Subject: [PATCH] test: Patch some holes in testing due to bad try/except/else syntax/understanding. Signed-off-by: Sebastien Awwad --- tests/test_updater.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_updater.py b/tests/test_updater.py index 4a223d42..d576397e 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -721,6 +721,10 @@ def test_3__update_metadata(self): for mirror_error in six.itervalues(e.mirror_errors): assert isinstance(mirror_error, securesystemslib.exceptions.BadVersionNumberError) + else: + self.fail( + 'Expected a NoWorkingMirrorError composed of BadVersionNumberErrors') + # Verify that the specific exception raised is correct for the previous # case. The version number is checked, so the specific error in # this case should be 'securesystemslib.exceptions.BadVersionNumberError'. @@ -733,6 +737,10 @@ def test_3__update_metadata(self): for mirror_error in six.itervalues(e.mirror_errors): assert isinstance(mirror_error, securesystemslib.exceptions.BadVersionNumberError) + else: + self.fail( + 'Expected a NoWorkingMirrorError composed of BadVersionNumberErrors') + @@ -1274,6 +1282,10 @@ def test_6_download_target(self): except OSError as e: self.assertTrue(e.errno == errno.ENAMETOOLONG or e.errno == errno.ENOENT) + else: + self.fail('Expected an OSError of type ENAMETOOLONG or ENOENT') + + # Test: Invalid arguments. self.assertRaises(securesystemslib.exceptions.FormatError, self.repository_updater.download_target, @@ -1303,6 +1315,12 @@ def test_6_download_target(self): # which does not generate specific exception errors. self.assertEqual(len(exception.mirror_errors), 0) + else: + self.fail( + 'Expected a NoWorkingMirrorError with zero mirror errors in it.') + + + def test_7_updated_targets(self):