|
58 | 58 | from _pytest.deprecated import check_ispytest |
59 | 59 | from _pytest.deprecated import INSTANCE_COLLECTOR |
60 | 60 | from _pytest.deprecated import NOSE_SUPPORT_METHOD |
| 61 | +from _pytest.fixtures import _get_direct_parametrize_args |
61 | 62 | from _pytest.fixtures import FixtureDef |
62 | 63 | from _pytest.fixtures import FixtureRequest |
63 | | -from _pytest.fixtures import _get_direct_parametrize_args |
64 | 64 | from _pytest.fixtures import FuncFixtureInfo |
65 | 65 | from _pytest.fixtures import get_scope_node |
66 | 66 | from _pytest.main import Session |
@@ -503,13 +503,15 @@ def _genfunctions(self, name: str, funcobj) -> Iterator["Function"]: |
503 | 503 | if not metafunc._calls: |
504 | 504 | yield Function.from_parent(self, name=name, fixtureinfo=fixtureinfo) |
505 | 505 | else: |
506 | | - |
507 | 506 | if hasattr(metafunc, "has_dynamic_parametrize"): |
508 | | - # add_funcarg_pseudo_fixture_def may have shadowed some fixtures |
509 | | - # due to dynamic direct parametrization so make sure we update |
510 | | - # what the function really needs. Note that we didn't need to do this if |
511 | | - # only indirect dynamic parametrization had taken place, but anyway we did |
512 | | - # it as differentiating between direct and indirect requires a dirty hack. |
| 507 | + # Parametrizations takeing place in module/class-specific `pytest_generate_tests` |
| 508 | + # hooks, a.k.a dynamic parametrizations, may have shadowed some fixtures |
| 509 | + # so make sure we update what the function really needs. |
| 510 | + # |
| 511 | + # Note that we didn't need to do this if only indirect dynamic parametrization had |
| 512 | + # taken place i.e. with `indirect=True`, but anyway we did it as differentiating |
| 513 | + # between direct and indirect requires a dirty hack. |
| 514 | + fm = self.session._fixturemanager |
513 | 515 | fixture_closure, _ = fm.getfixtureclosure( |
514 | 516 | definition, |
515 | 517 | fixtureinfo.initialnames, |
|
0 commit comments