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

Method test_rerun

testing/python/integration.py:297–333  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

295
296class TestReRunTests:
297 def test_rerun(self, pytester: Pytester) -> None:
298 pytester.makeconftest(
299 """
300 from _pytest.runner import runtestprotocol
301 def pytest_runtest_protocol(item, nextitem):
302 runtestprotocol(item, log=False, nextitem=nextitem)
303 runtestprotocol(item, log=True, nextitem=nextitem)
304 """
305 )
306 pytester.makepyfile(
307 """
308 import pytest
309 count = 0
310 req = None
311 @pytest.fixture
312 def fix(request):
313 global count, req
314 assert request != req
315 req = request
316 print("fix count %s" % count)
317 count += 1
318 def test_fix(fix):
319 pass
320 """
321 )
322 result = pytester.runpytest("-s")
323 result.stdout.fnmatch_lines(
324 """
325 *fix count 0*
326 *fix count 1*
327 """
328 )
329 result.stdout.fnmatch_lines(
330 """
331 *2 passed*
332 """
333 )
334
335
336def test_pytestconfig_is_session_scoped() -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
makeconftestMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected