-
-
Notifications
You must be signed in to change notification settings - Fork 650
Open
Description
👋 (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.pyfiles (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:conftestdependency (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
conftestdependency
🔬 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 inprojects/example/tests/BUILD.bazel, where specificallytest_subdir.pyhas a dependency on:conftest - On 1.6.0: Gazelle puts
conftest.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.3
Anything else relevant?
cosinequanon
Metadata
Metadata
Assignees
Labels
No labels