diff options
author | Kumar McMillan <kumar.mcmillan@gmail.com> | 2008-04-30 19:32:14 +0000 |
---|---|---|
committer | Kumar McMillan <kumar.mcmillan@gmail.com> | 2008-04-30 19:32:14 +0000 |
commit | 9a5d74bf585e0004ada95d4aaa6e3cb0b8d8a837 (patch) | |
tree | 7374d0169bc1760f33847acdf54911b374c0101d | |
parent | e7097bd484e8ebc9f204c8e204f0d507439f50ac (diff) | |
download | nose-9a5d74bf585e0004ada95d4aaa6e3cb0b8d8a837.tar.gz |
fixing test_address() so that it is compatible with unittest.TestCase classes which define __metaclass__ -- see http://code.google.com/p/python-nose/issues/detail?id=153
-rw-r--r-- | nose/util.py | 2 | ||||
-rw-r--r-- | unit_tests/test_utils.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/nose/util.py b/nose/util.py index b20eed1..0cce7d2 100644 --- a/nose/util.py +++ b/nose/util.py @@ -388,7 +388,7 @@ def test_address(test): file = getattr(test, '__file__', None) module = getattr(test, '__name__', None) return (file, module, call) - if t == types.FunctionType or t in (type, types.ClassType): + if t == types.FunctionType or issubclass(t, type) or t == types.ClassType: module = getattr(test, '__module__', None) if module is not None: m = sys.modules[module] diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index ede573a..e7da73c 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -74,6 +74,15 @@ class TestUtils(unittest.TestCase): def test_two(self): pass + class CustomTestType(type): + pass + class CustomTC(unittest.TestCase): + __metaclass__ = CustomTestType + def test_one(self): + pass + def test_two(self): + pass + foo_funct = case.FunctionTestCase(baz) foo_functu = unittest.FunctionTestCase(baz) @@ -93,6 +102,8 @@ class TestUtils(unittest.TestCase): # missed test plugin must do self.assertEqual(test_address(FooTC('test_one')), (me, __name__, 'FooTC.test_one')) + self.assertEqual(test_address(CustomTC('test_one')), + (me, __name__, 'CustomTC.test_one')) self.assertEqual(test_address(foo_funct), (me, __name__, 'baz')) self.assertEqual(test_address(foo_functu), |