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

Method test_class_ordering

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

Source from the content-addressed store, hash-verified

2698 )
2699
2700 def test_class_ordering(self, pytester: Pytester) -> None:
2701 pytester.makeini(
2702 """
2703 [pytest]
2704 console_output_style=classic
2705 """
2706 )
2707 pytester.makeconftest(
2708 """
2709 import pytest
2710
2711 values = []
2712
2713 @pytest.fixture(scope="function", params=[1,2])
2714 def farg(request):
2715 return request.param
2716
2717 @pytest.fixture(scope="class", params=list("ab"))
2718 def carg(request):
2719 return request.param
2720
2721 @pytest.fixture(scope="function", autouse=True)
2722 def append(request, farg, carg):
2723 def fin():
2724 values.append("fin_%s%s" % (carg, farg))
2725 request.addfinalizer(fin)
2726 """
2727 )
2728 pytester.makepyfile(
2729 """
2730 import pytest
2731
2732 class TestClass2(object):
2733 def test_1(self):
2734 pass
2735 def test_2(self):
2736 pass
2737 class TestClass(object):
2738 def test_3(self):
2739 pass
2740 """
2741 )
2742 result = pytester.runpytest("-vs")
2743 result.stdout.re_match_lines(
2744 r"""
2745 test_class_ordering.py::TestClass2::test_1\[a-1\] PASSED
2746 test_class_ordering.py::TestClass2::test_1\[a-2\] PASSED
2747 test_class_ordering.py::TestClass2::test_2\[a-1\] PASSED
2748 test_class_ordering.py::TestClass2::test_2\[a-2\] PASSED
2749 test_class_ordering.py::TestClass2::test_1\[b-1\] PASSED
2750 test_class_ordering.py::TestClass2::test_1\[b-2\] PASSED
2751 test_class_ordering.py::TestClass2::test_2\[b-1\] PASSED
2752 test_class_ordering.py::TestClass2::test_2\[b-2\] PASSED
2753 test_class_ordering.py::TestClass::test_3\[a-1\] PASSED
2754 test_class_ordering.py::TestClass::test_3\[a-2\] PASSED
2755 test_class_ordering.py::TestClass::test_3\[b-1\] PASSED
2756 test_class_ordering.py::TestClass::test_3\[b-2\] PASSED
2757 """

Callers

nothing calls this directly

Calls 5

re_match_linesMethod · 0.80
makeiniMethod · 0.45
makeconftestMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected