Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
conftest.py
to default to python_library
rather than `pyth…
…on_tests` (pantsbuild#10603) ### Problem `conftest.py` is (typically) a util file with no tests in it. Now that we always run tests one-file-at-a-time thanks to generated subtargets, this causes Pytest to try to run on `conftest.py`, which fails because there are no tests. More philosophically, test util code has always meant to go into `python_library`, rather than `python_tests`. A target is "metadata for some files" - it doesn't make sense to say something like `timeout=120` on `conftest.py`. ### Solution Change default source globs so that `conftest.py` will show up in `python_library()` now. ### Result Pytest no longer will error if you have a `conftest.py` and were using default source globs. If you already had a `python_library()` target in the directory where the `conftest.py` was defined—and you have `--python-infer-conftests` enabled (the default)—then you will not need to make any changes for this to work. If you only had a `python_tests()` target—and you have `--python-infer-conftests`—you simply need to add `python_library(name='conftest')` to your BUILD file. If you only had a `python_tests` target—and do not have `--python-infer-conftests`—you will need to add `python_library(name='conftest')` and also update your `python_tests()` to explicitly depend on that new target. For new users, their BUILD file will now look something like this in a folder that solely has tests + `conftest.py`: ``` python_tests() python_library(name="conftest") ``` [ci skip-rust] [ci skip-build-wheels]
- Loading branch information