diff -r 752b59a9b9cd Lib/unittest/loader.py --- a/Lib/unittest/loader.py Mon Jul 27 16:48:42 2015 +0300 +++ b/Lib/unittest/loader.py Mon Jul 27 14:23:45 2015 -0700 @@ -119,7 +119,9 @@ tests = [] for name in dir(module): obj = getattr(module, name) - if isinstance(obj, type) and issubclass(obj, case.TestCase): + if (isinstance(obj, type) and + issubclass(obj, case.TestCase) and + obj is not case.FunctionTestCase): tests.append(self.loadTestsFromTestCase(obj)) load_tests = getattr(module, 'load_tests', None) @@ -188,11 +190,14 @@ if isinstance(obj, types.ModuleType): return self.loadTestsFromModule(obj) - elif isinstance(obj, type) and issubclass(obj, case.TestCase): + elif (isinstance(obj, type) and + issubclass(obj, case.TestCase) and + obj is not case.FunctionTestCase): return self.loadTestsFromTestCase(obj) elif (isinstance(obj, types.FunctionType) and isinstance(parent, type) and - issubclass(parent, case.TestCase)): + issubclass(parent, case.TestCase) and + obj is not case.FunctionTestCase): name = parts[-1] inst = parent(name) # static methods follow a different path diff -r 752b59a9b9cd Lib/unittest/test/test_loader.py --- a/Lib/unittest/test/test_loader.py Mon Jul 27 16:48:42 2015 +0300 +++ b/Lib/unittest/test/test_loader.py Mon Jul 27 14:23:45 2015 -0700 @@ -147,7 +147,19 @@ self.assertEqual(list(suite), [loader.suiteClass()]) - # "This method searches `module` for classes derived from TestCase"s + # "This method searches `module` for classes derived from TestCase" + # + # What happens if FunctionTestCase is found? + def test_loadTestsFromModule__has_FunctionTestCase(self): + m = types.ModuleType('m') + m.testcase_1 = unittest.FunctionTestCase + + loader = unittest.TestLoader() + suite = loader.loadTestsFromModule(m) + self.assertIsInstance(suite, loader.suiteClass) + self.assertEqual(list(suite), []) + + # "This method searches `module` for classes derived from TestCase" # # What happens if loadTestsFromModule() is given something other # than a module?