Skip to content

Bad exec call in test breaks pytest #7742

@doerwalter

Description

@doerwalter

The following test file breaks pytest:

def test_bad():
	exec("a = 5", {}, [])

When I'm running the test file with pytest test_bad.py, I get the following output:

platform darwin -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /Users/walter/x
collected 1 item

test_bad.py
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/main.py", line 240, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/main.py", line 296, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/main.py", line 321, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/runner.py", line 100, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/runner.py", line 117, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/runner.py", line 209, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)  # type: TestReport
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/skipping.py", line 264, in pytest_runtest_makereport
INTERNALERROR>     rep = outcome.get_result()
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/runner.py", line 320, in pytest_runtest_makereport
INTERNALERROR>     return TestReport.from_item_and_call(item, call)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/reports.py", line 319, in from_item_and_call
INTERNALERROR>     longrepr = item.repr_failure(excinfo)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/python.py", line 1603, in repr_failure
INTERNALERROR>     return self._repr_failure_py(excinfo, style=style)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/nodes.py", line 372, in _repr_failure_py
INTERNALERROR>     self._prunetraceback(excinfo)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/python.py", line 1588, in _prunetraceback
INTERNALERROR>     excinfo.traceback = ntraceback.filter()
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/_code/code.py", line 363, in filter
INTERNALERROR>     return Traceback(filter(fn, self), self._excinfo)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/_code/code.py", line 301, in __init__
INTERNALERROR>     super().__init__(tb)
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/_code/code.py", line 352, in <lambda>
INTERNALERROR>     self, fn: Callable[[TracebackEntry], bool] = lambda x: not x.ishidden()
INTERNALERROR>   File "/Users/walter/pyvenvs/pytest-bad/lib/python3.8/site-packages/_pytest/_code/code.py", line 250, in ishidden
INTERNALERROR>     tbh = f.f_locals.get(
INTERNALERROR> AttributeError: 'list' object has no attribute 'get'

pip list reports the following:

Package        Version
-------------- -------
attrs          20.2.0
iniconfig      1.0.1
more-itertools 8.5.0
packaging      20.4
pip            20.2.3
pluggy         0.13.1
py             1.9.0
pyparsing      2.4.7
pytest         6.0.1
setuptools     47.1.0
six            1.15.0
toml           0.10.1

I have the following version of Python:

Python 3.8.5 (default, Jul 21 2020, 10:48:26)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin

This Python version was installed via Homebrew on macOS Catalina (Version 10.15.6).

Metadata

Metadata

Assignees

No one assigned

    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