Skip to content

Commit

Permalink
Only touch unittest-wrapped methods.
Browse files Browse the repository at this point in the history
method.__qualname__ does not play well with nose1 method wrappers (such
as nose.tools.raises, which leads to something like
`raises.<locals>.decorate.<locals>.newfunc`). Since this is a problem
with nose1, I decide to work around it here by only touching the
unittest-wrapped methods.
  • Loading branch information
ltfish committed Jun 10, 2020
1 parent c6861db commit 2cbc17f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nose2/util.py
Expand Up @@ -183,9 +183,12 @@ def test_name(test, qualname=True):
if hasattr(test, '_funcName'):
tid = test._funcName
elif hasattr(test, '_testFunc'):
# this is a UnitTest-wrapped function
if sys.version_info >= (3, 3):
tid = "%s.%s" % (test._testFunc.__module__, test._testFunc.__qualname__)
if any("__unittest" in attr for attr in dir(test._testFunc)):
# this is a UnitTest-wrapped function
if sys.version_info >= (3, 3):
tid = "%s.%s" % (test._testFunc.__module__, test._testFunc.__qualname__)
else:
tid = "%s.%s" % (test._testFunc.__module__, test._testFunc.__name__)
else:
tid = "%s.%s" % (test._testFunc.__module__, test._testFunc.__name__)
else:
Expand Down

0 comments on commit 2cbc17f

Please sign in to comment.