expect correct exception class for py3

This commit is contained in:
Alan Hamlett 2017-11-23 12:30:29 -08:00
parent 0ca8a936db
commit c6a5bf4086
2 changed files with 9 additions and 3 deletions

View file

@ -190,7 +190,7 @@ class ProjectTestCase(TestCase):
self.assertNothingPrinted() self.assertNothingPrinted()
actual = self.getLogOutput(logs) actual = self.getLogOutput(logs)
expected = 'OSError' if self.isPy35OrNewer else 'IOError' expected = 'OSError' if self.isPy33OrNewer else 'IOError'
self.assertIn(expected, actual) self.assertIn(expected, actual)
def test_git_detached_head_not_used_as_branch(self): def test_git_detached_head_not_used_as_branch(self):
@ -350,7 +350,7 @@ class ProjectTestCase(TestCase):
self.assertNothingPrinted() self.assertNothingPrinted()
actual = self.getLogOutput(logs) actual = self.getLogOutput(logs)
expected = 'OSError' if self.isPy35OrNewer else 'IOError' expected = 'OSError' if self.isPy33OrNewer else 'IOError'
self.assertIn(expected, actual) self.assertIn(expected, actual)
def test_git_submodule_detected(self): def test_git_submodule_detected(self):
@ -503,7 +503,7 @@ class ProjectTestCase(TestCase):
self.assertIsNone(result) self.assertIsNone(result)
self.assertNothingPrinted() self.assertNothingPrinted()
actual = self.getLogOutput(logs) actual = self.getLogOutput(logs)
expected = 'OSError' if self.isPy35OrNewer else 'IOError' expected = 'OSError' if self.isPy33OrNewer else 'IOError'
self.assertIn(expected, actual) self.assertIn(expected, actual)
@log_capture() @log_capture()

View file

@ -150,6 +150,12 @@ class TestCase(unittest.TestCase):
return True return True
return (sys.version_info[0] >= 3 and sys.version_info[1] >= 5) 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: try:
# Python >= 3 # Python >= 3