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

Function test_runtest_in_module_ordering

testing/test_runner.py:505–534  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

503
504@pytest.mark.xfail
505def test_runtest_in_module_ordering(pytester: Pytester) -> None:
506 p1 = pytester.makepyfile(
507 """
508 import pytest
509 def pytest_runtest_setup(item): # runs after class-level!
510 item.function.mylist.append("module")
511 class TestClass(object):
512 def pytest_runtest_setup(self, item):
513 assert not hasattr(item.function, 'mylist')
514 item.function.mylist = ['class']
515 @pytest.fixture
516 def mylist(self, request):
517 return request.function.mylist
518 @pytest.hookimpl(hookwrapper=True)
519 def pytest_runtest_call(self, item):
520 try:
521 (yield).get_result()
522 except ValueError:
523 pass
524 def test_hello1(self, mylist):
525 assert mylist == ['class', 'module'], mylist
526 raise ValueError()
527 def test_hello2(self, mylist):
528 assert mylist == ['class', 'module'], mylist
529 def pytest_runtest_teardown(item):
530 del item.function.mylist
531 """
532 )
533 result = pytester.runpytest(p1)
534 result.stdout.fnmatch_lines(["*2 passed*"])
535
536
537def test_outcomeexception_exceptionattributes() -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected