-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
The small test to reproduce
class Thing:
def __repr__(self):
raise NotImplementedError
def test_the_thing():
t = Thing()
assert t == 3
def test_something_works():
assert 1 == 1
When running tests with $ python3 -m pytest
everything works as expected
================================== test session starts ===================================
platform linux -- Python 3.6.7, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /home/kondratyev-nv/Development/repr_error, inifile:
plugins: describe-0.12.0
collected 2 items
repr_error_test.py F. [100%]
======================================== FAILURES ========================================
_____________________________________ test_the_thing _____________________________________
def test_the_thing():
t = Thing()
> assert t == 3
E assert <[NotImplementedError("") raised in repr()] Thing object at 0x7fd26100aa58> == 3
repr_error_test.py:8: AssertionError
=========================== 1 failed, 1 passed in 0.03 seconds ===========================
Adding -v
and -l
- $ python3 -m pytest
also works as expected
================================== test session starts ===================================
platform linux -- Python 3.6.7, pytest-4.3.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/kondratyev-nv/Development/repr_error, inifile:
plugins: describe-0.12.0
collected 2 items
repr_error_test.py::test_the_thing FAILED [ 50%]
repr_error_test.py::test_something_works PASSED [100%]
======================================== FAILURES ========================================
_____________________________________ test_the_thing _____________________________________
def test_the_thing():
t = Thing()
> assert t == 3
E assert <[NotImplemen...x7fcd312745c0> == 3
E (pytest_assertion plugin: representation of details failed. Probably an object has a faulty __repr__.)
E /home/kondratyev-nv/Development/repr_error/repr_error_test.py:3: NotImplementedError
t = <[NotImplementedError("") raised in repr()] Thing object at 0x7fcd312745c0>
repr_error_test.py:8: AssertionError
=========================== 1 failed, 1 passed in 0.03 seconds ===========================
But increasing verbosity ($ python3 -m pytest -l -vv
) leads to an INTERNALERROR.
================================== test session starts ===================================
platform linux -- Python 3.6.7, pytest-4.3.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/kondratyev-nv/Development/repr_error, inifile:
plugins: describe-0.12.0
collected 2 items
repr_error_test.py::test_the_thing
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/main.py", line 210, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/main.py", line 250, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/main.py", line 271, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/runner.py", line 78, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/runner.py", line 93, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/runner.py", line 175, in call_and_report
INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/skipping.py", line 127, in pytest_runtest_makereport
INTERNALERROR> rep = outcome.get_result()
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/runner.py", line 268, in pytest_runtest_makereport
INTERNALERROR> longrepr = item.repr_failure(excinfo)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/python.py", line 837, in repr_failure
INTERNALERROR> return self._repr_failure_py(excinfo, style=style)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/nodes.py", line 285, in _repr_failure_py
INTERNALERROR> truncate_locals=truncate_locals,
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/_code/code.py", line 556, in getrepr
INTERNALERROR> return fmt.repr_excinfo(self)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/_code/code.py", line 806, in repr_excinfo
INTERNALERROR> reprtraceback = self.repr_traceback(excinfo)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/_code/code.py", line 751, in repr_traceback
INTERNALERROR> reprentry = self.repr_traceback_entry(entry, einfo)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/_code/code.py", line 721, in repr_traceback_entry
INTERNALERROR> localsrepr = self.repr_locals(entry.locals)
INTERNALERROR> File "/home/kondratyev-nv/.local/lib/python3.6/site-packages/_pytest/_code/code.py", line 683, in repr_locals
INTERNALERROR> str_repr = pprint.pformat(value)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 58, in pformat
INTERNALERROR> compact=compact).pformat(object)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 144, in pformat
INTERNALERROR> self._format(object, sio, 0, 0, {}, 0)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 161, in _format
INTERNALERROR> rep = self._repr(object, context, level)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 393, in _repr
INTERNALERROR> self._depth, level)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 405, in format
INTERNALERROR> return _safe_repr(object, context, maxlevels, level)
INTERNALERROR> File "/usr/lib/python3.6/pprint.py", line 555, in _safe_repr
INTERNALERROR> rep = repr(object)
INTERNALERROR> File "/home/kondratyev-nv/Development/repr_error/repr_error_test.py", line 3, in __repr__
INTERNALERROR> raise NotImplementedError
INTERNALERROR> NotImplementedError
============================== no tests ran in 0.03 seconds ==============================
Also, notice that in the last example no tests are completed. I'm using Ubuntu 18.04, python 3.6.7, and pytest 4.3.0.
Can you please clarify if this is expected behaviour or a bug?
Metadata
Metadata
Assignees
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressedproblem that needs to be addressed