Randomized and parallel tests (#3151)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Rowlando13 · committed by GitHub · parents 4529351, c9e60ee · Browse files · 5 files·+84 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+84 added−2 removed
- other:+84 added−2 removed
Provenance
- Commit
a5cb82f- Tree
a32d2cf- Author
Rowlando13 <67291205+Rowlando13@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent 1
4529351- Parent 2
c9e60ee
5 files changed+84 added−2 removed
added:docs/contributing.md+21 added
123456789101112131415161718192021# Contributing
This is a quick reference for Click-specific development tasks. For setting up the development environment and the general contribution workflow, see the Pallets [quick reference](https://palletsprojects.com/contributing/quick/) and the [detailed contributing guide](https://palletsprojects.com/contributing/).
## Extra Test Environments
Click includes some extra test environments:
- `tox r -e stress` runs stress tests for race conditions in Click's test runner.
```shell-session $ tox r -e stress ```
- `tox r -e random` runs tests in parallel in a random order to detect test pollution.
```shell-session $ tox r -e random ```
- A CI workflow (`.github/workflows/test-flask.yaml`) runs Flask's test suite to catch downstream regressions.modified:docs/index.rst+1 added-2 removed
131 unmodified lines132 * This documentation is structured according to `Diataxis <https://diataxis.fr/>`_ and written with `MyST <https://myst-parser.readthedocs.io/en/latest/>`_133 134 * `Version Policy <https://palletsprojects.com/versions>`_135 136-* `Contributing <https://palletsprojects.com/contributing/>`_137-136 * `Donate <https://palletsprojects.com/donate>`_137 138 .. toctree::139 :maxdepth: 1140 141+ contributing142 contrib143 license144 changesmodified:CHANGES.rst+4 added
15 unmodified lines16 - Patch ``pdb.Pdb`` in ``CliRunner`` isolation so ``pdb.set_trace()``,17 ``breakpoint()``, and debuggers subclassing ``pdb.Pdb`` (ipdb, pdbpp) can18 interact with the real terminal instead of the captured I/O streams.19 :issue:`654` :issue:`824` :issue:`843` :pr:`951` :pr:`3235`20+- Add optional randomized parallel test execution using ``pytest-randomly`` and21+ ``pytest-xdist`` to detect test pollution and race conditions. :pr:`3151`22+- Add contributor documentation for running stress tests, randomized23+ parallel tests, and Flask smoke tests. :pr:`3151` :pr:`3177`24 25 Version 8.3.226 -------------27 1323 unmodified linesmodified:pyproject.toml+14 added
49 unmodified lines50 ]51 tests = [52 "pytest",53 ]54+tests-random = [55+ "pytest",56+ "pytest-randomly",57+ "pytest-xdist",58+]59 typing = [60 "mypy",61 "pyright",62 "pytest",106 unmodified lines169 "pytest", "-v", "--tb=short", "--basetemp={env_tmp_dir}",170 {replace = "posargs", default = [], extend = true},171 ]]172 173+[tool.tox.env.random]174+description = "randomized parallel tests to detect test pollution and race conditions"175+dependency_groups = ["tests-random"]176+commands = [[177+ "pytest", "-v", "--tb=short", "--numprocesses=auto",178+ "--basetemp={env_tmp_dir}",179+ {replace = "posargs", default = [], extend = true},180+]]181+182 [tool.tox.env.stress]183 description = "stress tests for stream lifecycle race conditions"184 commands = [[185 "pytest", "-v", "--tb=short", "-x", "-m", "stress",51 unmodified linesmodified:uv.lock+44 added
207 unmodified lines208 ]209 tests = [210 { name = "pytest" },211 ]212+tests-random = [213+ { name = "pytest" },214+ { name = "pytest-randomly" },215+ { name = "pytest-xdist" },216+]217 typing = [218 { name = "mypy" },219 { name = "pyright" },220 { name = "pytest" },21 unmodified lines242 { name = "pre-commit" },243 { name = "pre-commit-uv" },244 ]245 tests = [{ name = "pytest" }]246+tests-random = [247+ { name = "pytest" },248+ { name = "pytest-randomly" },249+ { name = "pytest-xdist" },250+]251 typing = [252 { name = "mypy" },253 { name = "pyright" },254 { name = "pytest" },54 unmodified lines309 { url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" },310 ]311 312 [[package]]313+name = "execnet"314+version = "2.1.2"315+source = { registry = "https://pypi.org/simple" }316+sdist = { url = "https://files.pythonhosted.org/packages/bf/89/780e11f9588d9e7128a3f87788354c7946a9cbb1401ad38a48c4db9a4f07/execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd", size = 166622, upload-time = "2025-11-12T09:56:37.75Z" }317+wheels = [318+ { url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec", size = 40708, upload-time = "2025-11-12T09:56:36.333Z" },319+]320+321+[[package]]322 name = "filelock"323 version = "3.25.2"324 source = { registry = "https://pypi.org/simple" }325 sdist = { url = "https://files.pythonhosted.org/packages/94/b8/00651a0f559862f3bb7d6f7477b192afe3f583cc5e26403b44e59a55ab34/filelock-3.25.2.tar.gz", hash = "sha256:b64ece2b38f4ca29dd3e810287aa8c48182bbecd1ae6e9ae126c9b35f1382694", size = 40480, upload-time = "2026-03-11T20:45:38.487Z" }587 unmodified lines913 { url = "https://files.pythonhosted.org/packages/67/0f/019d3949a40280f6193b62bc010177d4ce702d0fce424322286488569cd3/python_discovery-1.2.1-py3-none-any.whl", hash = "sha256:b6a957b24c1cd79252484d3566d1b49527581d46e789aaf43181005e56201502", size = 31674, upload-time = "2026-03-26T22:30:43.396Z" },914 ]915 916 [[package]]917+name = "pytest-randomly"918+version = "4.0.1"919+source = { registry = "https://pypi.org/simple" }920+dependencies = [921+ { name = "pytest" },922+]923+sdist = { url = "https://files.pythonhosted.org/packages/c4/1d/258a4bf1109258c00c35043f40433be5c16647387b6e7cd5582d638c116b/pytest_randomly-4.0.1.tar.gz", hash = "sha256:174e57bb12ac2c26f3578188490bd333f0e80620c3f47340158a86eca0593cd8", size = 14130, upload-time = "2025-09-12T15:23:00.085Z" }924+wheels = [925+ { url = "https://files.pythonhosted.org/packages/33/3e/a4a9227807b56869790aad3e24472a554b585974fe7e551ea350f50897ae/pytest_randomly-4.0.1-py3-none-any.whl", hash = "sha256:e0dfad2fd4f35e07beff1e47c17fbafcf98f9bf4531fd369d9260e2f858bfcb7", size = 8304, upload-time = "2025-09-12T15:22:58.946Z" },926+]927+928+[[package]]929+name = "pytest-xdist"930+version = "3.8.0"931+source = { registry = "https://pypi.org/simple" }932+dependencies = [933+ { name = "execnet" },934+ { name = "pytest" },935+]936+sdist = { url = "https://files.pythonhosted.org/packages/78/b4/439b179d1ff526791eb921115fca8e44e596a13efeda518b9d845a619450/pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1", size = 88069, upload-time = "2025-07-01T13:30:59.346Z" }937+wheels = [938+ { url = "https://files.pythonhosted.org/packages/ca/31/d4e37e9e550c2b92a9cbc2e4d0b7420a27224968580b5a447f420847c975/pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88", size = 46396, upload-time = "2025-07-01T13:30:56.632Z" },939+]940+941+[[package]]942 name = "pyyaml"943 version = "6.0.3"944 source = { registry = "https://pypi.org/simple" }945 sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" }720 unmodified lines