Apply comments
This commit is contained in:
parent
40b2c09ecf
commit
8b59725300
|
@ -40,7 +40,6 @@ from _pytest._code.code import Traceback
|
||||||
from _pytest._io import TerminalWriter
|
from _pytest._io import TerminalWriter
|
||||||
from _pytest._io.saferepr import saferepr
|
from _pytest._io.saferepr import saferepr
|
||||||
from _pytest.compat import ascii_escaped
|
from _pytest.compat import ascii_escaped
|
||||||
from _pytest.compat import assert_never
|
|
||||||
from _pytest.compat import get_default_arg_names
|
from _pytest.compat import get_default_arg_names
|
||||||
from _pytest.compat import get_real_func
|
from _pytest.compat import get_real_func
|
||||||
from _pytest.compat import getimfunc
|
from _pytest.compat import getimfunc
|
||||||
|
@ -1355,7 +1354,7 @@ class Metafunc:
|
||||||
elif scope_ is Scope.Package:
|
elif scope_ is Scope.Package:
|
||||||
node = collector.session
|
node = collector.session
|
||||||
else:
|
else:
|
||||||
assert_never(scope_) # type: ignore[arg-type]
|
assert False, f"Unhandled missing scope: {scope}"
|
||||||
if node is None:
|
if node is None:
|
||||||
name2pseudofixturedef = None
|
name2pseudofixturedef = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1551,6 +1551,10 @@ class TestMetafuncFunctional:
|
||||||
def test_parametrize_module_level_test_with_class_scope(
|
def test_parametrize_module_level_test_with_class_scope(
|
||||||
self, pytester: Pytester
|
self, pytester: Pytester
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""
|
||||||
|
Test that a class-scoped parametrization without a corresponding `Class`
|
||||||
|
gets module scope, i.e. we only create a single FixtureDef for it per module.
|
||||||
|
"""
|
||||||
module = pytester.makepyfile(
|
module = pytester.makepyfile(
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -1565,13 +1569,16 @@ class TestMetafuncFunctional:
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
test_1_0, _, test_2_0, _ = pytester.genitems((pytester.getmodulecol(module),))
|
test_1_0, _, test_2_0, _ = pytester.genitems((pytester.getmodulecol(module),))
|
||||||
test_1_fixture_x = cast(Function, test_1_0)._fixtureinfo.name2fixturedefs["x"][
|
|
||||||
-1
|
assert isinstance(test_1_0, Function)
|
||||||
]
|
assert test_1_0.name == "test_1[0]"
|
||||||
test_2_fixture_x = cast(Function, test_2_0)._fixtureinfo.name2fixturedefs["x"][
|
test_1_fixture_x = test_1_0._fixtureinfo.name2fixturedefs["x"][-1]
|
||||||
-1
|
|
||||||
]
|
assert isinstance(test_2_0, Function)
|
||||||
assert test_1_fixture_x == test_2_fixture_x
|
assert test_2_0.name == "test_2[1]"
|
||||||
|
test_2_fixture_x = test_2_0._fixtureinfo.name2fixturedefs["x"][-1]
|
||||||
|
|
||||||
|
assert test_1_fixture_x is test_2_fixture_x
|
||||||
|
|
||||||
|
|
||||||
class TestMetafuncFunctionalAuto:
|
class TestMetafuncFunctionalAuto:
|
||||||
|
|
Loading…
Reference in New Issue