pytest-regex
Select pytest tests with regular expressions
What it is and what it does
pytest-regex is a pytest plugin that extends test selection by allowing you to specify tests using Python regular expressions. Instead of pytest's `-k` flag (which does substring matching), you pass a `--regex` argument with a regex pattern that is matched against the full test node ID (e.g., `path/to/test_module.py::TestClass::test_name[parameter_value]`). Tests whose node IDs match the pattern are selected and run.
The plugin is useful when you need precise test selection that substring matching cannot easily express—for example, selecting only tests that end with exactly `test_3d` or choosing between similar test names. It was developed for use with large projects like SciPy where test discovery and selection can be complex. The package depends only on pytest and installs as a pure Python wheel with no compiled dependencies.
Use it for:
- Select tests by exact name suffix or prefix using anchored regex patterns (e.g., `.*test_3d$` to match only tests ending in `test_3d`)
- Filter tests across multiple modules or classes using a single regex pattern that matches the full node ID path
- Combine multiple test selection criteria in one regex that would be cumbersome or impossible with pytest's `-k` flag
- Run a subset of parametrized tests by matching parameter values embedded in the node ID
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that selects tests to run using Python regular expressions matched against test node IDs, offering finer control than pytest's built-in `-k` flag.
No. The package is abandoned (last release 2023-05-29, no commits since) and has minimal maintenance signal. While it solves a real problem—regex-based test selection—pytest's `-k` flag and other selection mechanisms are actively maintained and cover most use cases. Install only if you have a specific regex pattern requirement that `-k` cannot express and are willing to maintain a fork if needed.
Install
pytest-regex on PyPI
pip
pip install pytest-regexuv
uv add pytest-regexpoetry
poetry add pytest-regexInstalling pytest-regex
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. However, the package is abandoned—last release was 2023-05-29 and no commits since then—so expect no maintenance or bug fixes going forward.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or redistribution in your own projects.
Quickstart
pip install pytest-regex
python -m pytest --regex "(.*test_3d$|.*test_3d_example$)"
Verify before relying
- Whether the regex matching is applied to the full node ID or only specific parts of it
- Whether the plugin works with pytest parametrization and fixture combinations
- Performance impact when running against large test suites with complex regex patterns
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | abandoned — 1,173 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 112,819/month — #12,357 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_regex-0.2.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-mypy-pluginsA pytest plugin that runs type-checking tests…
permissive · top 15,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
regressProvides Python bindings to the Rust regress…
permissive · top 5,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
flpcflpc wraps the Rust regex crate to provide…
permissive · top 5,000 on PyPI
exrexExrex generates all or random strings matching…
agpl · top 15,000 on PyPI
repathConverts Express-style path strings (like…
permissive · top 15,000 on PyPI
pynosepynose is an updated test runner that extends…
copyleft · top 5,000 on PyPI
regexploitRegexploit analyzes regular expressions to…
permissive · top 15,000 on PyPI
greeneryParses and manipulates regular expressions by…
permissive · top 15,000 on PyPI