https://github.com/cryptaliagy/pytest-explicit
A pytest plugin for setting tests to be skipped by default
https://github.com/cryptaliagy/pytest-explicit
plugin pytest testing
Last synced: about 1 year ago
JSON representation
A pytest plugin for setting tests to be skipped by default
- Host: GitHub
- URL: https://github.com/cryptaliagy/pytest-explicit
- Owner: cryptaliagy
- License: mit
- Created: 2021-06-12T16:50:04.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-21T22:42:19.000Z (over 2 years ago)
- Last Synced: 2025-02-19T00:48:47.402Z (over 1 year ago)
- Topics: plugin, pytest, testing
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Pytest-Explicit
[](https://pypi.org/project/pytest-explicit/)
[](https://pypi.org/project/pytest-explicit/)
[](https://pypi.org/project/pytest-explicit/)
[](https://github.com/taliamax/pytest-explicit/actions/workflows/release.yaml)
[](https://pypi.org/project/pytest-explicit/)
[](https://github.com/taliamax/pytest-explicit/blob/main/LICENSE)
## Some tests you just don't want to run
Hey, I get it. Sometimes we write tests, but we don't actually want to wait
for them to finish executing. Whether they're slow tests, they need some
dependencies you don't have, or they aren't related to the work you
do, there's some tests that just weren't meant to be run by devs in the age
of CI/CD platforms. That's where `pytest-explicit` comes in.
This plugin allows developers to specify test markers that should be ignored
by default when running `pytest`, but also quickly bypass this behaviour
for CI/CD. Just add a `--run-all` flag to your pytest command for your test
pipeline, and this plugin won't skip anything!
## Configuring
If all you want to do is skip slow tests by default, you can stop reading
now. Out-of-the-box, `pytest-explicit` will make any test marked `slow`
require you to pass the `--run-slow` (or `--run-all`) for them to take
up precious developer time.
Need more ignored tests? Just add the `explicit-only` option to your
pytest config file, and `pytest-explicit` will pick up the markers
specified and dynamically add `--run-` CLI options to pytest. Here's
a sample `setup.cfg` file below!
```ini
[tool:pytest]
markers =
slow: Marks a slow test
memory_intensive: Marks a test that needs at least 16 gb RAM to run
smoke: Marks a test that gives early alert to the health of the app
testpaths = tests
explicit-only =
slow
memory_intensive
```
With this configuration file, any test marked with either `slow` or
`memory_intensive` won't run unless the appropriate CLI flags are passed!