From b1334bcc22a0ccebbfecc3a944d4b57d2cca86d8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 Jun 2015 06:46:03 +0200 Subject: [PATCH] Use repr() for unknown objects in utils.qualname. --- qutebrowser/utils/utils.py | 2 +- tests/utils/test_utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index b5f9ac25c..526a2a5e0 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -553,7 +553,7 @@ def qualname(obj): elif hasattr(obj, '__name__'): name = obj.__name__ else: - name = '' + name = repr(obj) if inspect.isclass(obj) or inspect.isfunction(obj): module = obj.__module__ diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index 04291dfdd..cc3d1817e 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -721,8 +721,11 @@ def qualname_func(_blah): pass +QUALNAME_OBJ = QualnameObj() + + @pytest.mark.parametrize('obj, expected', [ - (QualnameObj(), ''), # 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