Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
- {name: Random 3.10, python: '3.10', tox: random}
- {name: Random Windows, python: '3.15', tox: random, os: windows-latest}
- {name: Random Mac, python: '3.15', tox: random, os: macos-latest}
- {name: Stress 3.15, python: '3.15', tox: stress-py3.15}
- {name: Stress 3.15t, python: '3.15t', tox: stress-py3.15t}
- {name: Stress Mac 3.15t, python: '3.15t', tox: stress-py3.15t, os: macos-latest}
- {name: Stress 3.15, python: '3.15', tox: stress}
- {name: Stress 3.15t, python: '3.15t', tox: stress}
- {name: Stress Mac 3.15t, python: '3.15t', tox: stress, os: macos-latest}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down
7 changes: 7 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Click includes some extra test environments:
$ tox r -e stress
```

- `tox r -e stress-long` runs the stress tests that take
minutes.

```shell-session
$ tox r -e stress-long
```

- `tox r -e random` runs tests in parallel in a random
order to detect test pollution.

Expand Down
13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ filterwarnings = [
]
markers = [
"stress: high-iteration stress tests for race conditions (deselect with '-m \"not stress\"')",
"stress_long: high-iteration stress tests that take minutes (deselect with '-m \"not stress_long\"')",
]
addopts = "-m 'not stress'"
addopts = "-m 'not stress and not stress_long'"

[tool.coverage.run]
branch = true
Expand Down Expand Up @@ -147,7 +148,6 @@ env_list = [
"py3.15", "py3.14", "py3.13", "py3.12", "py3.11", "py3.10",
"py3.15t",
"pypy3.11",
"stress-py3.15", "stress-py3.15t",
"style",
"typing",
"docs",
Expand Down Expand Up @@ -184,6 +184,15 @@ commands = [[
{replace = "posargs", default = [], extend = true},
]]

[tool.tox.env.stress-long]
description = "high-iteration stress tests that take minutes"
commands = [[
"pytest", "-v", "--tb=short", "-x", "-m", "stress_long",
"--basetemp={env_tmp_dir}",
"--override-ini=addopts=",
{replace = "posargs", default = [], extend = true},
]]

[tool.tox.env.style]
description = "run all pre-commit hooks on all files"
dependency_groups = ["pre-commit"]
Expand Down
27 changes: 19 additions & 8 deletions tests/test_stream_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
3. Logging interaction: ``CliRunner`` works with active logging handlers
4. Multi-threaded safety: concurrent threads don't cause I/O-on-closed-file
5. Sequential invocations: multiple ``invoke()`` calls don't corrupt state
6. Stress tests (marked ``stress``): high-iteration reproducers for races
6. Stress tests (``stress``, ``stress_long``): high-iteration reproducers for races

How to run locally
------------------
Expand All @@ -28,12 +28,18 @@

$ pytest tests/test_stream_lifecycle.py -v

Stress tests only (30k iterations, ~52min):
Short stress tests only (20k iterations, ~11s):

.. code-block:: shell-session

$ pytest tests/test_stream_lifecycle.py -m stress -x --override-ini="addopts="

Long stress tests only (10k iterations, ~11min):

.. code-block:: shell-session

$ pytest tests/test_stream_lifecycle.py -m stress_long -x --override-ini="addopts="

Everything:

.. code-block:: shell-session
Expand Down Expand Up @@ -491,10 +497,11 @@ def cli():
# ---------------------------------------------------------------------------
# Category 6: Stress tests - high-iteration reproducers for race conditions
#
# These are marked with ``pytest.mark.stress`` so they can be included or
# excluded independently. The ``tox -e stress`` env collects every
# ``pytest.mark.stress`` test across the suite (not just this file), so
# stress regressions for other components live alongside their unit tests.
# These are marked with ``pytest.mark.stress``, or ``pytest.mark.stress_long`` when they
# take minutes, so they can be included or excluded independently. The ``tox -e stress``
# and ``tox -e stress-long`` envs collect every test with their marker across the suite
# (not just this file), so stress regressions for other components live alongside their
# unit tests.
# ---------------------------------------------------------------------------


Expand Down Expand Up @@ -534,10 +541,14 @@ def cli():
assert result.exit_code == 0


@pytest.mark.stress
@pytest.mark.stress_long
@pytest.mark.parametrize("_", range(10_000))
def test_stress_gc_between_invocations(_):
"""Force GC after each invocation to provoke finalizer races."""
"""Force GC after each invocation to provoke finalizer races.

Each full collection walks every object of the pytest session, so this test
takes minutes.
"""

@click.command()
def cli():
Expand Down
Loading