Generate lockfile for using pytest #5838
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
This is another part of introducing pants, as discussed in various TSC meetings.
Related PRs can be found in:
Overview of this PR
This configures pants so it can use
pytest
when running thetest
goal. However, our test suite does not completely support pytest. Getting this lockfile in is a prerequisite to being able to running tests with it.pytest version
I opted to go with the version of pytest that pants has pinned by default.
st2/pants.toml
Lines 147 to 149 in 43e2a1d
pytest plugins
By default pants includes
pytest-cov
andpytest-xdist
plugins for pytest. We get those too because I'm usingextra_requirements.add
; if I usedextra_requirements
it would overwrite those.st2/pants.toml
Line 150 in 43e2a1d
We already install
pytest-benchmark[histogram]
for our tests inst2common/benchmarks
, so I copied that pinned version as is:st2/test-requirements.txt
Line 41 in 43e2a1d
st2/pants.toml
Line 151 in 43e2a1d
Then I added several other plugins, some of which I left commented (we can check them out later when we do more with pytest):
st2/pants.toml
Lines 152 to 158 in 43e2a1d
This is partially based on recommendations in the pants docs. See: https://www.pantsbuild.org/docs/python-test-goal
These plugins have made what I've done with pytest so far, more enjoyable.
pytest args
As recommended at https://www.pantsbuild.org/docs/python-test-goal#controlling-output, I dropped the pytest header. Pants runs each test file separately to help with caching, so that header becomes very annoying and repetitive.
st2/pants.toml
Lines 164 to 166 in 43e2a1d
parallel tests with mongo
This line of the config builds on #5707, so that pants can safely run tests that use mongo in parallel.
st2/pants.toml
Line 167 in 43e2a1d
see: