MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_idfn_fixture

Method test_idfn_fixture

testing/python/integration.py:452–478  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

450 res.stdout.fnmatch_lines(["*spam-2*", "*ham-2*"])
451
452 def test_idfn_fixture(self, pytester: Pytester) -> None:
453 pytester.makepyfile(
454 """
455 import pytest
456
457 def idfn(param):
458 if param == 0:
459 return 'spam'
460 elif param == 1:
461 return 'ham'
462 else:
463 return None
464
465 @pytest.fixture(params=[0, 1], ids=idfn)
466 def a(request):
467 return request.param
468
469 @pytest.fixture(params=[1, 2], ids=idfn)
470 def b(request):
471 return request.param
472
473 def test_params(a, b):
474 pass
475 """
476 )
477 res = pytester.runpytest("--collect-only")
478 res.stdout.fnmatch_lines(["*spam-2*", "*ham-2*"])
479
480
481def test_function_instance(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected