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

Method test_packages

testing/test_cacheprovider.py:1088–1116  ·  view source on GitHub ↗

Regression test for #7758. The particular issue here was that Package nodes were included in the filtering, being themselves Modules for the __init__.py, even if they had failed Modules in them. The tests includes a test in an __init__.py file just to make sure the

(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

1086 assert result.ret == 0
1087
1088 def test_packages(self, pytester: Pytester) -> None:
1089 """Regression test for #7758.
1090
1091 The particular issue here was that Package nodes were included in the
1092 filtering, being themselves Modules for the __init__.py, even if they
1093 had failed Modules in them.
1094
1095 The tests includes a test in an __init__.py file just to make sure the
1096 fix doesn't somehow regress that, it is not critical for the issue.
1097 """
1098 pytester.makepyfile(
1099 **{
1100 "__init__.py": "",
1101 "a/__init__.py": "def test_a_init(): assert False",
1102 "a/test_one.py": "def test_1(): assert False",
1103 "b/__init__.py": "",
1104 "b/test_two.py": "def test_2(): assert False",
1105 },
1106 )
1107 pytester.makeini(
1108 """
1109 [pytest]
1110 python_files = *.py
1111 """
1112 )
1113 result = pytester.runpytest()
1114 result.assert_outcomes(failed=3)
1115 result = pytester.runpytest("--lf")
1116 result.assert_outcomes(failed=3)
1117
1118 def test_non_python_file_skipped(
1119 self,

Callers

nothing calls this directly

Calls 4

assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
makeiniMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected