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

Function test_fixture_scope_sibling_conftests

testing/test_collection.py:1003–1031  ·  view source on GitHub ↗

Regression test case for https://github.com/pytest-dev/pytest/issues/2836

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1001
1002
1003def test_fixture_scope_sibling_conftests(pytester: Pytester) -> None:
1004 """Regression test case for https://github.com/pytest-dev/pytest/issues/2836"""
1005 foo_path = pytester.mkdir("foo")
1006 foo_path.joinpath("conftest.py").write_text(
1007 textwrap.dedent(
1008 """\
1009 import pytest
1010 @pytest.fixture
1011 def fix():
1012 return 1
1013 """
1014 )
1015 )
1016 foo_path.joinpath("test_foo.py").write_text("def test_foo(fix): assert fix == 1")
1017
1018 # Tests in `food/` should not see the conftest fixture from `foo/`
1019 food_path = pytester.mkpydir("food")
1020 food_path.joinpath("test_food.py").write_text("def test_food(fix): assert fix == 1")
1021
1022 res = pytester.runpytest()
1023 assert res.ret == 1
1024
1025 res.stdout.fnmatch_lines(
1026 [
1027 "*ERROR at setup of test_food*",
1028 "E*fixture 'fix' not found",
1029 "*1 passed, 1 error*",
1030 ]
1031 )
1032
1033
1034def test_collect_init_tests(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
mkdirMethod · 0.45
mkpydirMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected