plugin.py 600 B

123456789101112131415161718192021222324
  1. import pytest
  2. from .lazy_fixture import LazyFixtureWrapper
  3. from .loader import load_lazy_fixtures
  4. from .normalizer import normalize_metafunc_calls
  5. @pytest.hookimpl(tryfirst=True)
  6. def pytest_fixture_setup(fixturedef, request):
  7. val = getattr(request, "param", None)
  8. if val is not None:
  9. request.param = load_lazy_fixtures(val, request)
  10. def pytest_make_parametrize_id(config, val, argname):
  11. if isinstance(val, LazyFixtureWrapper):
  12. return val.name
  13. @pytest.hookimpl(hookwrapper=True)
  14. def pytest_generate_tests(metafunc):
  15. yield
  16. normalize_metafunc_calls(metafunc)