A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead.

This commit is contained in:
Michael Foord 2010-03-21 00:53:39 +00:00
parent 134fb10408
commit 73dbe04619
2 changed files with 36 additions and 7 deletions

View file

@ -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()