MCPcopy
hub / github.com/pytest-dev/pytest / test_applymarker

Method test_applymarker

testing/python/fixtures.py:1308–1332  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

1306
1307class TestRequestMarking:
1308 def test_applymarker(self, pytester: Pytester) -> None:
1309 item1, _item2 = pytester.getitems(
1310 """
1311 import pytest
1312
1313 @pytest.fixture
1314 def something(request):
1315 pass
1316 class TestClass(object):
1317 def test_func1(self, something):
1318 pass
1319 def test_func2(self, something):
1320 pass
1321 """
1322 )
1323 assert isinstance(item1, Function)
1324 req1 = TopRequest(item1, _ispytest=True)
1325 assert "xfail" not in item1.keywords
1326 req1.applymarker(pytest.mark.xfail)
1327 assert "xfail" in item1.keywords
1328 assert "skipif" not in item1.keywords
1329 req1.applymarker(pytest.mark.skipif)
1330 assert "skipif" in item1.keywords
1331 with pytest.raises(ValueError):
1332 req1.applymarker(42) # type: ignore[arg-type]
1333
1334 def test_accesskeywords(self, pytester: Pytester) -> None:
1335 pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

TopRequestClass · 0.90
applymarkerMethod · 0.80
getitemsMethod · 0.45

Tested by

no test coverage detected