diff options
author | Christian Lyder Jacobsen <christian@paperlessreceipts.co.uk> | 2014-05-08 16:00:37 +0100 |
---|---|---|
committer | Christian Lyder Jacobsen <christian@paperlessreceipts.co.uk> | 2014-05-08 16:17:02 +0100 |
commit | fcd11ab9e2a3db760b4c82d65853a44f45e69d68 (patch) | |
tree | 4f345243886f335a9cb453d0cc1c620221f1fdd9 | |
parent | 6f95c7dd363ed6626442279b841dc03f0b7a81d4 (diff) | |
download | nose-fcd11ab9e2a3db760b4c82d65853a44f45e69d68.tar.gz |
Fix for try_run when using bound methods
-rw-r--r-- | nose/util.py | 2 | ||||
-rw-r--r-- | unit_tests/test_utils.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/nose/util.py b/nose/util.py index e612696..e6f735e 100644 --- a/nose/util.py +++ b/nose/util.py @@ -452,7 +452,7 @@ def try_run(obj, names): inspect.getargspec(func) else: # Not a function. If it's callable, call it anyway - if hasattr(func, '__call__'): + if hasattr(func, '__call__') and not inspect.ismethod(func): func = func.__call__ try: args, varargs, varkw, defaults = \ diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index cd9ba6e..df6a98c 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -170,16 +170,22 @@ class TestUtils(unittest.TestCase): def __call__(self, mod): pass + class Bar_method: + def method(self): + pass + foo = imp.new_module('foo') foo.bar = bar foo.bar_m = bar_m foo.i_bar = Bar() foo.i_bar_m = Bar_m() + foo.i_bar_m = Bar_method().method try_run(foo, ('bar',)) try_run(foo, ('bar_m',)) try_run(foo, ('i_bar',)) try_run(foo, ('i_bar_m',)) + try_run(foo, ('i_bar_method',)) if __name__ == '__main__': unittest.main() |