Use repr() for unknown objects in utils.qualname.
This commit is contained in:
parent
dfe98d1053
commit
b1334bcc22
@ -553,7 +553,7 @@ def qualname(obj):
|
||||
elif hasattr(obj, '__name__'):
|
||||
name = obj.__name__
|
||||
else:
|
||||
name = '<unknown>'
|
||||
name = repr(obj)
|
||||
|
||||
if inspect.isclass(obj) or inspect.isfunction(obj):
|
||||
module = obj.__module__
|
||||
|
@ -721,8 +721,11 @@ def qualname_func(_blah):
|
||||
pass
|
||||
|
||||
|
||||
QUALNAME_OBJ = QualnameObj()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('obj, expected', [
|
||||
(QualnameObj(), '<unknown>'), # instance - unknown
|
||||
(QUALNAME_OBJ, repr(QUALNAME_OBJ)), # instance - unknown
|
||||
(QualnameObj, 'test_utils.QualnameObj'), # class
|
||||
(QualnameObj.func, 'test_utils.QualnameObj.func'), # unbound method
|
||||
(QualnameObj().func, 'test_utils.QualnameObj.func'), # bound method
|
||||
|
Loading…
Reference in New Issue
Block a user