pytest-probability 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. pytest_probability-0.3.1/AGENTS.md +47 -0
  2. pytest_probability-0.3.1/CLAUDE.md +1 -0
  3. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/PKG-INFO +1 -1
  4. pytest_probability-0.3.1/agcoord.toml +16 -0
  5. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/changelog.md +6 -0
  6. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/conf.py +2 -2
  7. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/installation.md +2 -2
  8. pytest_probability-0.3.1/gardenia.toml +8 -0
  9. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/pyproject.toml +1 -1
  10. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/src/pytest_probability/__init__.py +1 -1
  11. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/src/pytest_probability/plugin.py +46 -5
  12. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_gate_items.py +44 -0
  13. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/.gitignore +0 -0
  14. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/.readthedocs.yaml +0 -0
  15. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/LICENSE +0 -0
  16. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/README.md +0 -0
  17. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/bdd.md +0 -0
  18. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/cases.md +0 -0
  19. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/contributing.md +0 -0
  20. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/cost.md +0 -0
  21. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/index.md +0 -0
  22. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/internals.md +0 -0
  23. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/json-report.md +0 -0
  24. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/parametrization.md +0 -0
  25. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/quickstart.md +0 -0
  26. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/reference.md +0 -0
  27. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/requirements.txt +0 -0
  28. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/running.md +0 -0
  29. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/docs/statistics.md +0 -0
  30. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/src/pytest_probability/explain.py +0 -0
  31. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/src/pytest_probability/stats.py +0 -0
  32. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/conftest.py +0 -0
  33. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_explain.py +0 -0
  34. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_latency.py +0 -0
  35. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_plan.py +0 -0
  36. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_plugin.py +0 -0
  37. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_sequential.py +0 -0
  38. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_stats.py +0 -0
  39. {pytest_probability-0.3.0 → pytest_probability-0.3.1}/tests/test_stop.py +0 -0
@@ -0,0 +1,47 @@
1
+ # pytest-probability contributor instructions
2
+
3
+ See [README.md](README.md) and [docs/index.md](docs/index.md) (including [docs/contributing.md](docs/contributing.md) and the rest of [docs/](docs/)) for project overview, usage, and documentation.
4
+
5
+ - Keep statistical reference and test-only dependencies (`scipy`, `statsmodels`, `pytest-xdist`) strictly in `[project.optional-dependencies].test` in `pyproject.toml`, never in runtime `dependencies`.
6
+
7
+ <!-- gardenia:begin -->
8
+ - File an issue (`#N — one sentence describing the work`) for each code, test, docs, or packaging
9
+ change; work in an issue-named `/var/tmp` worktree from `origin/main`, keep the primary checkout
10
+ read-only, and keep check logs complete (never truncated).
11
+ - Verify behavior at public boundaries with focused tests (bug fixes start with a failing one) and
12
+ add canonical docs plus a `CHANGELOG.md` entry for user-facing changes. Tests stop and remove all
13
+ they create and never touch `~/.codex`, `~/.claude`, `~/.gemini`, `~/.config`, or `~/.local`.
14
+ - Docs-only changes (every path `README.md`, `CHANGELOG.md`, `AGENTS.md`, Markdown in `docs/`, or
15
+ a `docs/assets/` `.png`/`.svg` with provenance in `docs/assets/README.md`) skip tests and the
16
+ gate; verify the PR file list and diff, then merge via the forge.
17
+ - Gate and land only through `agc run` / `agc land <pr>`.
18
+ - Never put private project names, machine-local paths, or other repositories' issue links in
19
+ tracked files, commits, or pull requests.
20
+ - PyPI uploads and live host or production changes need explicit owner approval per operation.
21
+ <!-- gardenia:end -->
22
+
23
+ <!-- agrein:begin -->
24
+ Use the installed agrein skills: ticket-delivery before changing code, docs,
25
+ config, infrastructure, or live state; epic-queue when decomposing multi-ticket
26
+ work or coordinating subagent workers; bug-investigation before fixing defects or
27
+ failing checks; and owner-escalation for unsettled product/policy rulings, live
28
+ operation approvals, and decision handoffs. An assigned leaf worker implements
29
+ its ticket directly without recursively delegating it.
30
+ <!-- agrein:end -->
31
+
32
+ <!-- agroute:begin -->
33
+ Before delegating an authorized task to a worker, invoke the installed `agroute` and `howhard` skills to inspect live
34
+ quota, select an eligible route, and honor `needs_review` and the native or cross-agent execution plan; report
35
+ unavailable routing or exhausted quota instead of bypassing them. Afterward, record the truthful outcome and measured
36
+ usage in `howhard` memory. Assigned leaf workers execute their task directly, without recursive delegation.
37
+ <!-- agroute:end -->
38
+
39
+ <!-- agcoord:begin -->
40
+ When running checks or landing pull requests, follow the installed `agcoord` skill: pass a
41
+ short plain-English `--label` and integer byte resource claims with `agc run`, and keep
42
+ heavy checks portable for overflow unless they are host-bound. Where `agc repo-config` reports
43
+ repository defaults (`agcoord.toml` or `[tool.agcoord]`), let them supply claims and the
44
+ `full` or `land` gate command, and pass only what you need to change. Use one `agc land` request
45
+ for gate and publication. Never run `agc` recursively inside an admitted job or merge a
46
+ pull request directly.
47
+ <!-- agcoord:end -->
@@ -0,0 +1 @@
1
+ AGENTS.md
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pytest-probability
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: pytest plugin for nondeterministic tests: run cases N times, report empirical pass fractions, flaky detection, and cost.
5
5
  Project-URL: Homepage, https://github.com/xu-hao/pytest-probability
6
6
  Project-URL: Repository, https://github.com/xu-hao/pytest-probability
@@ -0,0 +1,16 @@
1
+ [gate]
2
+ command = ["python", "-m", "pytest", "-q"]
3
+ no_overflow = true
4
+
5
+ [gate.resources]
6
+ cpu = 4
7
+ memory = "4G"
8
+
9
+ [run]
10
+ no_overflow = true
11
+
12
+ [run.resources]
13
+ cpu = { default = 4 }
14
+ memory = { type = "bytes", default = "4G" }
15
+ tmpfs = { type = "bytes", requires = ["memory", "tmpfs_inodes"] }
16
+ tmpfs_inodes = { default = 262144, requires = ["tmpfs"] }
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 (2026-12-01)
4
+
5
+ - **pytest 9.2 compatibility:** fixed `--lf`/`--ff` reruns of failed verdict
6
+ items and `pytest-xdist` `--dist loadgroup` grouping under pytest 9.2's
7
+ structured `NodeId` representation while preserving pytest 7.4/8.x support.
8
+
3
9
  ## 0.3.0 (2026-10-09)
4
10
 
5
11
  - **Visible output change:** with more than one run, every summary row
@@ -3,8 +3,8 @@
3
3
  project = "pytest-probability"
4
4
  author = "Hao Xu"
5
5
  copyright = "2026, Hao Xu"
6
- release = "0.3.0"
7
- version = "0.3.0"
6
+ release = "0.3.1"
7
+ version = "0.3.1"
8
8
 
9
9
  extensions = [
10
10
  "myst_parser",
@@ -31,7 +31,7 @@ point — there is nothing to enable. Two quick checks:
31
31
  $ pytest --version -v
32
32
  ...
33
33
  registered plugins:
34
- probability-0.3.0 at .../pytest_probability/plugin.py
34
+ probability-0.3.1 at .../pytest_probability/plugin.py
35
35
  ```
36
36
 
37
37
  ```text
@@ -43,7 +43,7 @@ $ pytest --help | grep -A2 prob-runs
43
43
  The header of every test session also lists it:
44
44
 
45
45
  ```text
46
- plugins: probability-0.3.0
46
+ plugins: probability-0.3.1
47
47
  ```
48
48
 
49
49
  ## Disabling the plugin
@@ -0,0 +1,8 @@
1
+ # Tracked repository profile managed by gardenia.
2
+ gate = "python -m pytest -q"
3
+ claude_symlink = true
4
+ tools = ["agrein", "agroute", "agcoord"]
5
+
6
+ [params.gardenia]
7
+ changelog = true
8
+ docs_exemption = true
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-probability"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "pytest plugin for nondeterministic tests: run cases N times, report empirical pass fractions, flaky detection, and cost."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -8,7 +8,7 @@ from pytest_probability.plugin import (
8
8
  record_usage,
9
9
  )
10
10
 
11
- __version__ = "0.3.0"
11
+ __version__ = "0.3.1"
12
12
  __all__ = [
13
13
  "CurtailmentWarning",
14
14
  "InfeasibleGateWarning",
@@ -2552,7 +2552,42 @@ def _usage_to_dict(u: Any) -> dict[str, Any]:
2552
2552
  _clock: Callable[[], float] = time.perf_counter
2553
2553
 
2554
2554
 
2555
- class BenchItem(pytest.Item):
2555
+ class _ProbItem(pytest.Item):
2556
+ """Shared base for ``BenchItem`` and ``VerdictItem``.
2557
+
2558
+ On pytest >= 9.2, ``Node`` stores its identity as a structured
2559
+ ``NodeId`` in ``_id`` rather than a string in ``_nodeid``:
2560
+
2561
+ - passing the string ``nodeid`` lets pytest parse any ``[...]``
2562
+ suffix into ``NodeId.params`` so ``item.id`` matches the
2563
+ ``NodeId.parse(...)`` keys that ``LFPlugin`` reloads from
2564
+ ``cache/lastfailed``;
2565
+ - bridging ``_nodeid`` onto ``_id`` keeps ``pytest-xdist``'s
2566
+ ``--dist loadgroup`` (which appends ``@group`` by assigning
2567
+ ``item._nodeid``) working on pytest 9.2.
2568
+ """
2569
+
2570
+ if hasattr(pytest.Item, "id"):
2571
+
2572
+ def __init__(self, **kwargs: Any) -> None:
2573
+ parent = kwargs.get("parent")
2574
+ name = kwargs.get("name")
2575
+ if "nodeid" not in kwargs and parent is not None and name is not None:
2576
+ kwargs["nodeid"] = (
2577
+ f"{parent.nodeid}::{name}" if parent.nodeid else name
2578
+ )
2579
+ super().__init__(**kwargs)
2580
+
2581
+ @property
2582
+ def _nodeid(self) -> str:
2583
+ return str(self._id)
2584
+
2585
+ @_nodeid.setter
2586
+ def _nodeid(self, value: str) -> None:
2587
+ self._id = type(self._id).parse(value)
2588
+
2589
+
2590
+ class BenchItem(_ProbItem):
2556
2591
  """One (case, run) execution of a bench function.
2557
2592
 
2558
2593
  The function body is an ordinary pytest test body: a passing body
@@ -2962,7 +2997,7 @@ class _Verdict(NamedTuple):
2962
2997
  paragraphs: tuple[str, ...] = ()
2963
2998
 
2964
2999
 
2965
- class VerdictItem(pytest.Item):
3000
+ class VerdictItem(_ProbItem):
2966
3001
  """An item that runs after the bench items a verdict needs and
2967
3002
  passes or fails with that verdict, so ``-v``, JUnit XML and ``--lf``
2968
3003
  see it like any test.
@@ -3160,13 +3195,13 @@ class VerdictItems:
3160
3195
  lastfailed = getattr(lf, "lastfailed", None)
3161
3196
  if not getattr(lf, "active", False) or not lastfailed:
3162
3197
  return
3163
- failed = {v.key for v in verdict_items if v.nodeid in lastfailed}
3198
+ failed = {v.key for v in verdict_items if _lf_key(v) in lastfailed}
3164
3199
  if not failed:
3165
3200
  return
3166
- added: set[str] = set()
3201
+ added: set[Any] = set()
3167
3202
  for key, runs in _runs_by_key(items).items():
3168
3203
  if key in failed:
3169
- added.update(r.nodeid for r in runs if r.nodeid not in lastfailed)
3204
+ added.update(_lf_key(r) for r in runs if _lf_key(r) not in lastfailed)
3170
3205
  lastfailed.update(dict.fromkeys(added, True))
3171
3206
  self._rerun = (len(added), len(failed))
3172
3207
 
@@ -3210,6 +3245,12 @@ class VerdictItems:
3210
3245
  return None
3211
3246
 
3212
3247
 
3248
+ def _lf_key(item: pytest.Item) -> Any:
3249
+ # pytest >= 9.2 keys LFPlugin.lastfailed by NodeId (item.id);
3250
+ # earlier pytest keys it by the string item.nodeid.
3251
+ return getattr(item, "id", item.nodeid)
3252
+
3253
+
3213
3254
  def _plural(n: int, noun: str) -> str:
3214
3255
  return f"{n} {noun}{'' if n == 1 else 's'}"
3215
3256
 
@@ -416,6 +416,50 @@ def test_lf_keeps_real_failures_with_the_gates(pytester):
416
416
  result.assert_outcomes(passed=3, failed=2)
417
417
 
418
418
 
419
+ def test_lf_reruns_failed_margin_item_with_its_function(pytester):
420
+ pytester.makepyfile(bench_s=_PAIRED)
421
+ first = pytester.runpytest("--tb=no", "-q")
422
+ assert first.ret == pytest.ExitCode.TESTS_FAILED
423
+ result = pytester.runpytest("--tb=no", "--lf", "-v")
424
+ result.stdout.fnmatch_lines(
425
+ [
426
+ "run-last-failure: rerun previous 37 failures",
427
+ "probability: rerunning 36 runs with the 1 failed verdict item that"
428
+ " needs them",
429
+ ]
430
+ )
431
+ names = [i for i, _ in _items(result)]
432
+ assert len(names) == 37
433
+ assert names[-1] == "bench_s.py::bench_pair[compare:never]"
434
+ assert "bench_s.py::bench_pair[compare:same]" not in names
435
+ result.assert_outcomes(passed=24, failed=1, xfailed=12)
436
+
437
+
438
+ def test_items_keep_structured_id_and_nodeid_in_sync(pytester):
439
+ # On pytest >= 9.2, Node stores a structured NodeId in _id; custom
440
+ # BenchItem/GateItem/MarginItem instances must match NodeId.parse(nodeid)
441
+ # (for LFPlugin's cache/lastfailed) and reflect _nodeid writes (for
442
+ # pytest-xdist --dist loadgroup).
443
+ pytester.makepyfile(bench_s=_bench(CLASSIFY) + _PAIRED.split("\n", 2)[2])
444
+ pytester.makeconftest(
445
+ """
446
+ def pytest_collection_modifyitems(items):
447
+ for item in items:
448
+ if hasattr(item, "id"):
449
+ assert item.id == type(item.id).parse(item.nodeid)
450
+ orig = item.nodeid
451
+ item._nodeid = f"{orig}@grp"
452
+ assert item.nodeid == f"{orig}@grp"
453
+ assert item.id == type(item.id).parse(f"{orig}@grp")
454
+ item._nodeid = orig
455
+ assert item.nodeid == orig
456
+ assert item.id == type(item.id).parse(orig)
457
+ """
458
+ )
459
+ result = _run(pytester, "--collect-only", "-q")
460
+ assert result.ret == pytest.ExitCode.OK
461
+
462
+
419
463
  # ---------------------------------------------------------------------------
420
464
  # Selection
421
465
  # ---------------------------------------------------------------------------