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:970–1009  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

968
969
970def test_parameterset_for_fail_at_collect(pytester: Pytester) -> None:
971 pytester.makeini(
972 """
973 [pytest]
974 {}=fail_at_collect
975 """.format(
976 EMPTY_PARAMETERSET_OPTION
977 )
978 )
979
980 config = pytester.parseconfig()
981 from _pytest.mark import pytest_configure, get_empty_parameterset_mark
982
983 pytest_configure(config)
984
985 with pytest.raises(
986 Collector.CollectError,
987 match=r"Empty parameter set in 'pytest_configure' at line \d\d+",
988 ):
989 get_empty_parameterset_mark(config, ["a"], pytest_configure)
990
991 p1 = pytester.makepyfile(
992 """
993 import pytest
994
995 @pytest.mark.parametrize("empty", [])
996 def test():
997 pass
998 """
999 )
1000 result = pytester.runpytest(str(p1))
1001 result.stdout.fnmatch_lines(
1002 [
1003 "collected 0 items / 1 error",
1004 "* ERROR collecting test_parameterset_for_fail_at_collect.py *",
1005 "Empty parameter set in 'test' at line 3",
1006 "*= 1 error in *",
1007 ]
1008 )
1009 assert result.ret == ExitCode.INTERRUPTED
1010
1011
1012def test_parameterset_for_parametrize_bad_markname(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected