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

Function test_parameterset_for_fail_at_collect

testing/test_mark.py:1026–1064  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1024
1025
1026def test_parameterset_for_fail_at_collect(pytester: Pytester) -> None:
1027 pytester.makeini(
1028 f"""
1029 [pytest]
1030 {EMPTY_PARAMETERSET_OPTION}=fail_at_collect
1031 """
1032 )
1033
1034 config = pytester.parseconfig()
1035 from _pytest.mark import get_empty_parameterset_mark
1036 from _pytest.mark import pytest_configure
1037
1038 pytest_configure(config)
1039
1040 with pytest.raises(
1041 Collector.CollectError,
1042 match=r"Empty parameter set in 'pytest_configure' at line \d\d+",
1043 ):
1044 get_empty_parameterset_mark(config, ["a"], pytest_configure)
1045
1046 p1 = pytester.makepyfile(
1047 """
1048 import pytest
1049
1050 @pytest.mark.parametrize("empty", [])
1051 def test():
1052 pass
1053 """
1054 )
1055 result = pytester.runpytest(str(p1))
1056 result.stdout.fnmatch_lines(
1057 [
1058 "collected 0 items / 1 error",
1059 "* ERROR collecting test_parameterset_for_fail_at_collect.py *",
1060 "Empty parameter set in 'test' at line 3",
1061 "*= 1 error in *",
1062 ]
1063 )
1064 assert result.ret == ExitCode.INTERRUPTED
1065
1066
1067def test_paramset_empty_no_idfunc(

Callers

nothing calls this directly

Calls 7

pytest_configureFunction · 0.90
fnmatch_linesMethod · 0.80
makeiniMethod · 0.45
parseconfigMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…