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

Function test_parametrize_iterator

testing/test_mark.py:449–468  ·  view source on GitHub ↗

`parametrize` should work with generators (#5354).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

447
448
449def test_parametrize_iterator(pytester: Pytester) -> None:
450 """`parametrize` should work with generators (#5354)."""
451 py_file = pytester.makepyfile(
452 """\
453 import pytest
454
455 def gen():
456 yield 1
457 yield 2
458 yield 3
459
460 @pytest.mark.parametrize('a', gen())
461 def test(a):
462 assert a >= 1
463 """
464 )
465 result = pytester.runpytest(py_file)
466 assert result.ret == 0
467 # should not skip any tests
468 result.stdout.fnmatch_lines(["*3 passed*"])
469
470
471class TestFunctional:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected