-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pytest runner mode #355
base: main
Are you sure you want to change the base?
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 <[email protected]> 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. |
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 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 [email protected]
Closes: #354
TODO: