Add pytest runner mode#355
Open
mtreinish wants to merge 14 commits into
Open
Conversation
This commit adds a new runner mode to stestr that enables users to run test suites using pytest instead of unittest. This is an opt-in feature as for compatibility reasons we'll always default to using unittest, as all existing stestr users have only been leveraging unittest to run tests. A pytest plugin that adds a subunit output mode is now bundled with stestr. When the user specifies running tests with pytest it calls out to pytest just as stestr does with the integrated unittest extension today and sets the appropriate flags to enable subunit output. To facilitate this new feature pytest is added to the stestr requirements list. I debated making it an optional dependency, but to make it easier for the significantly larger pytest user base (it's downloaded ~900x more per month) it seemed simpler to just make it a hard requirement. But I'm still not 100% on this decision so if there is sufficient pushback we can start it out as an optional dependency. Co-Authored-By: Joe Gordon <jogo@pinterest.com> Closes: #354
This commit adds a return code subclass that executes the tests in pytest mode written with the pytest test suite. These tests caught a couple of issues when running in pytest mode.
This commit adds a new CI job that runs stestr's unit test suite in pytest mode instead of using stestr's built in subunit runner (based on stdlib unittest).
This commit fixes the mocking used for the config file tests. It was previously implicitly defining a runner argument as a mock object which wasn't a valid choice for a config file to contain after parsing. This commit just explicitly sets the mock to have the unittest runner set to avoid failure.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
==========================================
- Coverage 61.95% 59.18% -2.78%
==========================================
Files 30 31 +1
Lines 2618 2761 +143
Branches 426 463 +37
==========================================
+ Hits 1622 1634 +12
- Misses 877 1006 +129
- Partials 119 121 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Owner
Author
|
Hmm, testing on windows is failing: https://github.com/mtreinish/stestr/actions/runs/6835221394/job/18588774544?pr=355#step:6:18 I'm not really sure what that error means. It is at least working fine on Linux and macOS. |
d4bf013 to
cbbe2fc
Compare
…n windows" This reverts commit cbbe2fc.
The pytest subunit plugin was loading test paths incorrectly on windows as a posix path. This was causing the test loading to fail unexpectedly because pytest was unable to process the posix path version of a windows path. This commit fixes this issue in the pytest plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit adds a new runner mode to stestr that enables users to run test suites using pytest instead of unittest. This is an opt-in feature as for compatibility reasons we'll always default to using unittest, as all existing stestr users have only been leveraging unittest to run tests. A pytest plugin that adds a subunit output mode is now bundled with stestr. When the user specifies running tests with pytest it calls out to pytest just as stestr does with the integrated unittest extension today and sets the appropriate flags to enable subunit output.
To facilitate this new feature pytest is added to the stestr requirements list. I debated making it an optional dependency, but to make it easier for the significantly larger pytest user base (it's downloaded ~900x more per month) it seemed simpler to just make it a hard requirement. But I'm still not 100% on this decision so if there is sufficient pushback we can start it out as an optional dependency.
Co-Authored-By: Joe Gordon jogo@pinterest.com
Closes: #354
TODO: