diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-03-21 00:53:39 +0000 |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-03-21 00:53:39 +0000 |
commit | 73dbe0461986208564f64e80a7b79264a6a38368 (patch) | |
tree | 58235809668fdad075a0731a2af197d0f3486b09 /Lib/test/test_unittest.py | |
parent | 134fb10408d3f710c401c73443781a39c0c1a7ba (diff) | |
download | cpython-git-73dbe0461986208564f64e80a7b79264a6a38368.tar.gz |
A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead.
Diffstat (limited to 'Lib/test/test_unittest.py')
-rw-r--r-- | Lib/test/test_unittest.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index 5228e764fc..e094923cd3 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -289,6 +289,21 @@ class Test_TestLoader(TestCase): suite = loader.loadTestsFromModule(m, use_load_tests=False) self.assertEquals(load_tests_args, []) + def test_loadTestsFromModule__faulty_load_tests(self): + m = types.ModuleType('m') + + def load_tests(loader, tests, pattern): + raise TypeError('some failure') + m.load_tests = load_tests + + loader = unittest.TestLoader() + suite = loader.loadTestsFromModule(m) + self.assertIsInstance(suite, unittest.TestSuite) + self.assertEqual(suite.countTestCases(), 1) + test = list(suite)[0] + + self.assertRaisesRegexp(TypeError, "some failure", test.m) + ################################################################ ### /Tests for TestLoader.loadTestsFromModule() |