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

Method test_request_garbage

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

Source from the content-addressed store, hash-verified

709 reason="this method of test doesn't work on pypy",
710 )
711 def test_request_garbage(self, pytester: Pytester) -> None:
712 try:
713 import xdist # noqa
714 except ImportError:
715 pass
716 else:
717 pytest.xfail("this test is flaky when executed with xdist")
718 pytester.makepyfile(
719 """
720 import sys
721 import pytest
722 from _pytest.fixtures import PseudoFixtureDef
723 import gc
724
725 @pytest.fixture(autouse=True)
726 def something(request):
727 original = gc.get_debug()
728 gc.set_debug(gc.DEBUG_SAVEALL)
729 gc.collect()
730
731 yield
732
733 try:
734 gc.collect()
735 leaked = [x for _ in gc.garbage if isinstance(_, PseudoFixtureDef)]
736 assert leaked == []
737 finally:
738 gc.set_debug(original)
739
740 def test_func():
741 pass
742 """
743 )
744 result = pytester.runpytest_subprocess()
745 result.stdout.fnmatch_lines(["* 1 passed in *"])
746
747 def test_getfixturevalue_recursive(self, pytester: Pytester) -> None:
748 pytester.makeconftest(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytest_subprocessMethod · 0.45

Tested by

no test coverage detected