From 49899690a8867029076b1a336678479750fd78c9 Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Mon, 22 Mar 2010 01:41:11 +0000 Subject: [PATCH] Removing Python 2.3 compatibility code from unittest. --- Lib/test/test_unittest.py | 4 +++- Lib/unittest/loader.py | 6 +----- Lib/unittest/main.py | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index f003208a0a3..05c0182bfaf 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -4021,13 +4021,15 @@ class TestDiscovery(TestCase): program._do_discovery(['-p', 'fish'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'fish', None)]) + self.assertFalse(program.failfast) Loader.args = [] program = object.__new__(TestProgram) - program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v'], Loader=Loader) + program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v', '-f'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'eggs', None)]) self.assertEqual(program.verbosity, 2) + self.assertTrue(program.failfast) class TestSetups(unittest.TestCase): diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index d6c8d842451..022ed578160 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -30,11 +30,7 @@ VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE) def _make_failed_import_test(name, suiteClass): - message = 'Failed to import test module: %s' % name - if hasattr(traceback, 'format_exc'): - # Python 2.3 compatibility - # format_exc returns two frames of discover.py as well - message += '\n%s' % traceback.format_exc() + message = 'Failed to import test module: %s\n%s' % (name, traceback.format_exc()) return _make_failed_test('ModuleImportFailure', name, ImportError(message), suiteClass) diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py index f5b516cbb97..8fd23c0691e 100644 --- a/Lib/unittest/main.py +++ b/Lib/unittest/main.py @@ -159,10 +159,9 @@ class TestProgram(object): for name, value in zip(('start', 'pattern', 'top'), args): setattr(options, name, value) + self.failfast = options.failfast if options.verbose: self.verbosity = 2 - if options.failfast: - self.failfast = True start_dir = options.start pattern = options.pattern