diff options
author | Michael Williamson <mike@zwobble.org> | 2013-01-07 11:14:49 +0000 |
---|---|---|
committer | Michael Williamson <mike@zwobble.org> | 2013-01-07 11:14:49 +0000 |
commit | bee2720b041e7a030124273dac6d39da562e4738 (patch) | |
tree | b93e4c02f8afeb85cef839a639e8f7958abc9a54 /unit_tests/test_loader.py | |
parent | e879960507d51a4510a0900c784676951fc9581b (diff) | |
download | nose-bee2720b041e7a030124273dac6d39da562e4738.tar.gz |
Fix: missing method on test class from another module raises Error
Diffstat (limited to 'unit_tests/test_loader.py')
-rw-r--r-- | unit_tests/test_loader.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/unit_tests/test_loader.py b/unit_tests/test_loader.py index 08f0686..1f622a5 100644 --- a/unit_tests/test_loader.py +++ b/unit_tests/test_loader.py @@ -34,6 +34,7 @@ def mods(): 'test_module_with_generators') M['test_module_with_metaclass_tests'] = imp.new_module( 'test_module_with_metaclass_tests') + M['test_transplant'] = imp.new_module('test_transplant') # a unittest testcase subclass class TC(unittest.TestCase): @@ -105,6 +106,11 @@ def mods(): def try_odd(v): assert v % 2 + + # test class defined in one module and used in another + class Transplant(unittest.TestCase): + def runTest(self): + pass M['nose'] = nose M['__main__'] = sys.modules['__main__'] @@ -125,6 +131,8 @@ def mods(): try_odd.__module__ = 'test_module_with_generators' M['test_module_with_metaclass_tests'].TestMetaclassed = TestMetaclassed TestMetaclassed.__module__ = 'test_module_with_metaclass_tests' + M['test_transplant'].Transplant = Transplant + Transplant.__module__ = 'test_class_source' del TC del TC2 del TestMetaclassed @@ -132,6 +140,7 @@ def mods(): del test_func del TestClass del test_func_generator + del Transplant return M M = mods() @@ -354,6 +363,17 @@ class TestTestLoader(unittest.TestCase): tests[0](res) assert res.errors, "Expected missing method test to raise exception" + def test_load_from_name_module_transplanted_class_missing_method(self): + print "load from name module transplanted class missing method" + res = unittest.TestResult() + l = self.l + suite = l.loadTestsFromName('test_transplant:Transplant.testThat') + tests = [t for t in suite] + assert len(tests) == 1, \ + "Should have loaded 1 test, but got %s" % tests + tests[0](res) + assert res.errors, "Expected missing method test to raise exception" + def test_load_from_name_missing_module(self): print "load from name missing module" res = unittest.TestResult() |