From c6a5bf408699204ed64f76c118dbab25a634fa53 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Thu, 23 Nov 2017 12:30:29 -0800 Subject: [PATCH] expect correct exception class for py3 --- tests/test_project.py | 6 +++--- tests/utils.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 79e76f9..ff7453c 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -190,7 +190,7 @@ class ProjectTestCase(TestCase): self.assertNothingPrinted() actual = self.getLogOutput(logs) - expected = 'OSError' if self.isPy35OrNewer else 'IOError' + expected = 'OSError' if self.isPy33OrNewer else 'IOError' self.assertIn(expected, actual) def test_git_detached_head_not_used_as_branch(self): @@ -350,7 +350,7 @@ class ProjectTestCase(TestCase): self.assertNothingPrinted() actual = self.getLogOutput(logs) - expected = 'OSError' if self.isPy35OrNewer else 'IOError' + expected = 'OSError' if self.isPy33OrNewer else 'IOError' self.assertIn(expected, actual) def test_git_submodule_detected(self): @@ -503,7 +503,7 @@ class ProjectTestCase(TestCase): self.assertIsNone(result) self.assertNothingPrinted() actual = self.getLogOutput(logs) - expected = 'OSError' if self.isPy35OrNewer else 'IOError' + expected = 'OSError' if self.isPy33OrNewer else 'IOError' self.assertIn(expected, actual) @log_capture() diff --git a/tests/utils.py b/tests/utils.py index 939f586..bb46d4f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -150,6 +150,12 @@ class TestCase(unittest.TestCase): return True return (sys.version_info[0] >= 3 and sys.version_info[1] >= 5) + @property + def isPy33OrNewer(self): + if sys.version_info[0] > 3: + return True + return (sys.version_info[0] >= 3 and sys.version_info[1] >= 3) + try: # Python >= 3