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

Function test_markers_from_parametrize

testing/test_mark.py:1067–1101  ·  view source on GitHub ↗

#3605

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1065
1066@pytest.mark.filterwarnings("ignore")
1067def test_markers_from_parametrize(pytester: Pytester) -> None:
1068 """#3605"""
1069 pytester.makepyfile(
1070 """
1071 import pytest
1072
1073 first_custom_mark = pytest.mark.custom_marker
1074 custom_mark = pytest.mark.custom_mark
1075 @pytest.fixture(autouse=True)
1076 def trigger(request):
1077 custom_mark = list(request.node.iter_markers('custom_mark'))
1078 print("Custom mark %s" % custom_mark)
1079
1080 @custom_mark("custom mark non parametrized")
1081 def test_custom_mark_non_parametrized():
1082 print("Hey from test")
1083
1084 @pytest.mark.parametrize(
1085 "obj_type",
1086 [
1087 first_custom_mark("first custom mark")("template"),
1088 pytest.param( # Think this should be recommended way?
1089 "disk",
1090 marks=custom_mark('custom mark1')
1091 ),
1092 custom_mark("custom mark2")("vm"), # Tried also this
1093 ]
1094 )
1095 def test_custom_mark_parametrized(obj_type):
1096 print("obj_type is:", obj_type)
1097 """
1098 )
1099
1100 result = pytester.runpytest()
1101 result.assert_outcomes(passed=4)
1102
1103
1104def test_pytest_param_id_requires_string() -> None:

Callers

nothing calls this directly

Calls 3

assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected