-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: collectionrelated to the collection phaserelated to the collection phasetopic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
pytest crashes when trying to collect the following file:
@deco
def test():
pass
platform linux -- Python 3.8.0a2+, pytest-4.3.2.dev108+gaff72776.d20190322, py-1.8.1.dev3+g60f50bdc.d20190322, pluggy-0.9.0
rootdir: …/Vcs/pytest, inifile: tox.ini
plugins: xdist-1.27.0, forked-1.0.2, cov-2.6.1
collecting ... INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 209, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 248, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in <lambda>
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 258, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 485, in perform_collect
INTERNALERROR> items = self._perform_collect(args, genitems)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 524, in _perform_collect
INTERNALERROR> self.items.extend(self.genitems(node))
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/main.py", line 759, in genitems
INTERNALERROR> rep = collect_one_node(node)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/runner.py", line 371, in collect_one_node
INTERNALERROR> rep = ihook.pytest_make_collect_report(collector=collector)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 59, in <lambda>
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/capture.py", line 203, in pytest_make_collect_report
INTERNALERROR> rep = outcome.get_result()
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "…/Vcs/pytest/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/runner.py", line 267, in pytest_make_collect_report
INTERNALERROR> errorinfo = collector.repr_failure(call.excinfo)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/nodes.py", line 328, in repr_failure
INTERNALERROR> return self._repr_failure_py(excinfo, style="short")
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/nodes.py", line 279, in _repr_failure_py
INTERNALERROR> return excinfo.getrepr(
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/_code/code.py", line 551, in getrepr
INTERNALERROR> return fmt.repr_excinfo(self)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/_code/code.py", line 801, in repr_excinfo
INTERNALERROR> reprtraceback = self.repr_traceback(excinfo)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/_code/code.py", line 746, in repr_traceback
INTERNALERROR> reprentry = self.repr_traceback_entry(entry, einfo)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/_code/code.py", line 706, in repr_traceback_entry
INTERNALERROR> s = self.get_source(source, line_index, excinfo, short=short)
INTERNALERROR> File "…/Vcs/pytest/src/_pytest/_code/code.py", line 638, in get_source
INTERNALERROR> lines.append(space_prefix + source.lines[line_index].strip())
INTERNALERROR> IndexError: list index out of range
The failure representation works with --assert=plain
:
collected 0 items / 1 errors
===================== ERRORS =====================
_____ ERROR collecting testing/test_code.py ______
test_code.py:1: in <module>
@deco
E NameError: name 'deco' is not defined
============ short test summary info =============
FAILED test_code.py
!!!! Interrupted: 1 errors during collection !!!!!
I've started writing a test, but it fails in both modes like the first case above:
@pytest.mark.parametrize("assert_rewrite", ("plain", "rewrite"))
def test_collect_error_nameerror_with_decorator(assert_rewrite, testdir):
p1 = testdir.makepyfile(
"""
@deco
def f():
pass
""")
result = testdir.runpytest(str(p1), "--assert=%s" % assert_rewrite)
result.stdout.fnmatch_lines([
"*ERROR collecting test_collect_error_nameerror_with_decorator.py*",
"test_collect_error.py:1: in <module>",
"> @deco",
"E NameError: name 'deco' is not defined",
"test_collect_error_nameerror_with_decorator1: NameError",
])
Metadata
Metadata
Assignees
Labels
topic: collectionrelated to the collection phaserelated to the collection phasetopic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed