Skip to content

Crash on parametrize(..., scope="package") without a Package #11255

@bluetech

Description

@bluetech

The following test crashes:

import pytest

@pytest.mark.parametrize("x", [0], scope="package")
def test_it(x): pass

with this traceback:

src/_pytest/runner.py:340: in from_call
    result: Optional[TResult] = func()
src/_pytest/runner.py:371: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
src/_pytest/python.py:530: in collect
    return super().collect()
src/_pytest/python.py:451: in collect
    res = ihook.pytest_pycollect_makeitem(
.tox/venv/lib/python3.11/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
.tox/venv/lib/python3.11/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
src/_pytest/python.py:267: in pytest_pycollect_makeitem
    return list(collector._genfunctions(name, obj))
src/_pytest/python.py:501: in _genfunctions
    fixtures.add_funcarg_pseudo_fixture_def(self, metafunc, fm)
src/_pytest/fixtures.py:195: in add_funcarg_pseudo_fixture_def
    assert scope is Scope.Class and isinstance(
E   AssertionError

Metadata

Metadata

Assignees

Labels

topic: parametrizerelated to @pytest.mark.parametrizetype: 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