👋 (I searched conftest in the issues, closed and open, and didn't find a relevant issue)
🐞 bug report
Affected Rule
The issue is caused by the rule: `py_test` (and `py_library`) (and Gazelle)
Is this a regression?
Kinda yes, kinda no? The previous version in which this bug was not present was: 1.5.4 (pre 1.6.X)
Description
I'm having some heartburn updating past 1.6.0 due to #2998 (I'll probably dump those in another issue), but one that sticks out is how Gazelle handles (or doesn't handle) ancestor conftest.py.
(See the repro for code structure)
- Pytest loads ancestor
conftest.py files (not just the ones in the test file's directory). See the docs
- Old Gazelle rules had all the test targets in the
tests/ dir, meaning they got the :conftest dependency (even if they were in descendant directories)
- New Gazelle rules have the test in the test's parent directory (this is a good thing 👍) but now those targets no longer get the automatic ancestor
conftest dependency
🔬 Minimal Reproduction
Given this structure (all files empty, except for projects/repro/BUILD.bazel which has # gazelle:python_root)
<root>/
└── projects/
└── repro/
├── BUILD.bazel
└── tests/
├── BUILD.bazel
├── conftest.py
├── test_root_dir.py
└── subdir/
└── test_subdir.py
- On
1.5.4: Gazelle will put everything in projects/example/tests/BUILD.bazel, where specifically test_subdir.py has a dependency on :conftest
- On 1.6.0: Gazelle puts
conftest.py and test_root_dir.py targets in projects/example/tests/BUILD.bazel (with the test depending on :conftest) but projects/example/tests/subdir:test_subdir doesn't depend on conftest.py anymore)
🔥 Exception or Error
(If you put fixtures/hooks in conftest.py, especially ones with automagically execute, they won't work)
🌍 Your Environment
N/A
Rules_python version:
1.6.3
Anything else relevant?
👋 (I searched
conftestin the issues, closed and open, and didn't find a relevant issue)🐞 bug report
Affected Rule
The issue is caused by the rule: `py_test` (and `py_library`) (and Gazelle)Is this a regression?
Kinda yes, kinda no? The previous version in which this bug was not present was: 1.5.4 (pre 1.6.X)Description
I'm having some heartburn updating past 1.6.0 due to #2998 (I'll probably dump those in another issue), but one that sticks out is how Gazelle handles (or doesn't handle) ancestor
conftest.py.(See the repro for code structure)
conftest.pyfiles (not just the ones in the test file's directory). See the docstests/dir, meaning they got the:conftestdependency (even if they were in descendant directories)conftestdependency🔬 Minimal Reproduction
Given this structure (all files empty, except for
projects/repro/BUILD.bazelwhich has# gazelle:python_root)1.5.4: Gazelle will put everything inprojects/example/tests/BUILD.bazel, where specificallytest_subdir.pyhas a dependency on:conftestconftest.pyandtest_root_dir.pytargets inprojects/example/tests/BUILD.bazel(with the test depending on:conftest) butprojects/example/tests/subdir:test_subdirdoesn't depend onconftest.pyanymore)🔥 Exception or Error
(If you put fixtures/hooks in
conftest.py, especially ones with automagically execute, they won't work)🌍 Your Environment
N/A
Rules_python version:
1.6.3Anything else relevant?