Skip to content

Bug: Assertion raises INTERNALERROR with options --tb=line --junitxml=junit.xml #7707

@parijatm

Description

@parijatm

ReprEntry throws INTERNALERROR if you attempt to assert (with message) within a test.
Bug is encountered on pytest version 6.0 and above with options --tb=line --junitxml=junit.xml
(Not encountered on versions 5.4.3 and below)

To Reproduce:

Run
pytest --tb=line --junitxml=junit.xml
for the following test:

def test_ReprEntry_Assertion():
    assert False, 'Triggers INTERNALERROR from TerminalWriter'

Observed output:

============================================================== test session starts ===============================================================
platform linux -- Python 3.6.8, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /c/Users/parijatm/CodeBase/pytest
plugins: cov-2.8.1, timeout-1.3.4
collected 1 item                                                                                                                                 

test_tiny.py F
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/python3.6/site-packages/_pytest/main.py", line 240, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/python3.6/site-packages/_pytest/main.py", line 296, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/main.py", line 321, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/runner.py", line 100, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/runner.py", line 117, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "/python3.6/site-packages/_pytest/runner.py", line 211, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/junitxml.py", line 606, in pytest_runtest_logreport
INTERNALERROR>     reporter.append_failure(report)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/junitxml.py", line 227, in append_failure
INTERNALERROR>     fail.append(bin_xml_escape(report.longrepr))
INTERNALERROR>   File "/python3.6/site-packages/_pytest/junitxml.py", line 82, in bin_xml_escape
INTERNALERROR>     return py.xml.raw(illegal_xml_re.sub(repl, py.xml.escape(str(arg))))
INTERNALERROR>   File "/python3.6/site-packages/_pytest/_code/code.py", line 905, in __str__
INTERNALERROR>     self.toterminal(tw)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/_code/code.py", line 951, in toterminal
INTERNALERROR>     element[0].toterminal(tw)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/_code/code.py", line 981, in toterminal
INTERNALERROR>     entry.toterminal(tw)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/_code/code.py", line 1079, in toterminal
INTERNALERROR>     self._write_entry_lines(tw)
INTERNALERROR>   File "/python3.6/site-packages/_pytest/_code/code.py", line 1050, in _write_entry_lines
INTERNALERROR>     + "\n".join(self.lines)
INTERNALERROR> AssertionError: Unexpected failure lines between source lines:
INTERNALERROR> E   AssertionError: Triggers INTERNALERROR from TerminalWriter
INTERNALERROR>     assert False

========================================================== 1 failed, 1 warning in 0.38s ==========================================================

Issue appears to be with the 'not' in the following assertion:

assert not seeing_failures, (

Metadata

Metadata

Assignees

Labels

topic: reportingrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions