https://pantsbuild.org/ logo
#general
Title
# general
b

brash-baker-91190

02/01/2022, 7:54 PM
I'm going to preface this by acknowledging that it's a weird question: Is there a way to specify different sets of
pytest
configuration declaratively (or even non-declaratively!) for different subsets of tests? Something like having different extra-requirements (https://www.pantsbuild.org/docs/reference-pytest#section-extra-requirements) for unit tests vs. integration tests?
s

salmon-planet-80683

02/01/2022, 7:56 PM
(Chris's teammate here: We are thinking of doing --pytest-args="--no-cov")
👋 1
b

brash-baker-91190

02/01/2022, 7:57 PM
Yeah, that's probably the route we're going to end up going, but now I'm curious about the general case of different configurations for different segments of code... seems like a potentially interesting pattern 😄
h

hundreds-father-404

02/01/2022, 7:57 PM
The current way you do that is:
Alternatively, if you only want to install the plugin for certain tests, you can add the plugin to the dependencies field of your python_test / python_tests target. See Third-party dependencies for how to install Python dependencies. For example:
https://www.pantsbuild.org/docs/python-test-goal#pytest-version-and-plugins Will that work for you?
And then you can leverage
conftest.py
to dynamically change Pytest options etc on a per-test basis, iiuc
b

brash-baker-91190

02/01/2022, 7:59 PM
Ah, interesting! Thanks! We'll probably stick with
--no-cov
, but I'll keep this in mind for the future.
❤️ 1
h

hundreds-father-404

02/01/2022, 8:00 PM
I don't think I follow the
--no-cov
thing - is that to turn off coverage for all tests?
b

brash-baker-91190

02/01/2022, 8:01 PM
Yeah... it's really more of a peculiarity with our current testing setup, though.
Want to keep coverage for unit tests, but disable it for integration / end-to-end tests.
4 Views