diff options
-rw-r--r-- | nose/util.py | 3 | ||||
-rw-r--r-- | unit_tests/test_utils.py | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/nose/util.py b/nose/util.py index 529eebc..536d627 100644 --- a/nose/util.py +++ b/nose/util.py @@ -440,7 +440,8 @@ def test_address(test): method_name = test._testMethodName return (src(cls_adr[0]), cls_adr[1], "%s.%s" % (cls_adr[2], method_name)) - if hasattr(test, '__class__') and test.__class__.__module__ != 'builtins': + if (hasattr(test, '__class__') and + test.__class__.__module__ not in ('__builtin__', 'builtins')): return test_address(test.__class__) raise TypeError("I don't know what %s is (%s)" % (test, t)) test_address.__test__ = False # do not collect diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index 13ccf6f..2bd837c 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -113,6 +113,10 @@ class TestUtils(unittest.TestCase): self.assertEqual(test_address(foo_mtc), (me, __name__, 'Foo.bar')) + # verify that we fail on an invalid input type + self.assertRaises(TypeError, test_address, 1) + self.assertRaises(TypeError, test_address, "foo") + def test_isclass_detects_classes(self): class TC(unittest.TestCase): pass |