Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): pin pytest-rerunfailures to 16.6 (#116319)

Raúl Negrón-Otero17d986cb764c
diff --git a/posthog/test/test_junit_report_location.py b/posthog/test/test_junit_report_location.py
index af6e14c5d476..1fbb0bb40ae6 100644
--- a/posthog/test/test_junit_report_location.py
+++ b/posthog/test/test_junit_report_location.py
@@ -1,3 +1,7 @@
+import os
+import sys
+import subprocess
+from collections import Counter
from io import StringIO
from pathlib import Path
from types import SimpleNamespace
@@ -141,6 +145,38 @@ def test_retry_failure_uses_separate_junit_file(tmp_path: Path, when: Literal["s
assert failure.get("message") == "first failure"
+def test_a_test_that_fails_every_attempt_is_written_to_junit_once(tmp_path: Path) -> None:
+ (tmp_path / "pytest.ini").write_text("[pytest]\n")
+ (tmp_path / "test_always_fails.py").write_text(
+ "import pytest\n"
+ "\n"
+ "\n"
+ "@pytest.fixture\n"
+ "def broken():\n"
+ " raise RuntimeError('setup always fails')\n"
+ "\n"
+ "\n"
+ "def test_setup_errors(broken):\n"
+ " pass\n"
+ "\n"
+ "\n"
+ "def test_call_fails():\n"
+ " assert False\n"
+ )
+ environment = {name: value for name, value in os.environ.items() if name != "PYTEST_ADDOPTS"}
+
+ subprocess.run(
+ [sys.executable, "-m", "pytest", "-p", "pytest_rerunfailures", "--force-reruns", "1", "--junitxml=junit.xml"],
+ cwd=tmp_path,
+ env={**environment, "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1"},
+ capture_output=True,
+ check=False,
+ )
+
+ testcases = ElementTree.parse(tmp_path / "junit.xml").getroot().iter("testcase")
+ assert Counter(testcase.get("name") for testcase in testcases) == {"test_setup_errors": 1, "test_call_fails": 1}
+
+
def test_retry_junit_removes_stale_file_without_reruns(tmp_path: Path) -> None:
junit_path = tmp_path / "junit.xml"
retry_path = tmp_path / "junit-retry-failures.xml"
diff --git a/pyproject.toml b/pyproject.toml
index 989d13f581a8..4c53a82a2879 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -242,7 +242,8 @@ dev = [
"flameprof~=0.4",
"hypothesis~=6.151.9",
"pyinstrument~=5.1",
- "pytest-rerunfailures~=16.7",
+ # 16.6.1 and later write a retried failure to JUnit as an extra passing <testcase>, which reads as pass-on-retry.
+ "pytest-rerunfailures==16.6",
"time-machine==3.5.1",
"mypy~=2.1.0",
"mypy-extensions~=1.1.0",
diff --git a/uv.lock b/uv.lock
index b0efc2c78337..cfb872d2ec46 100644
--- a/uv.lock
+++ b/uv.lock
@@ -6300,7 +6300,7 @@ dev = [
{ name = "pytest-env", specifier = "~=1.7.1" },
{ name = "pytest-icdiff", specifier = "~=0.9" },
{ name = "pytest-mock", specifier = "~=3.15.1" },
- { name = "pytest-rerunfailures", specifier = "~=16.7" },
+ { name = "pytest-rerunfailures", specifier = "==16.6" },
{ name = "pytest-split", git = "https://github.com/PostHog/pytest-split?tag=v0.11.0-posthog.8" },
{ name = "pytest-timeout", specifier = "~=2.4.0" },
{ name = "pytest-xdist", specifier = "~=3.8.0" },
@@ -7127,15 +7127,15 @@ wheels = [
[[package]]
name = "pytest-rerunfailures"
-version = "16.7"
+version = "16.6"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "packaging" },
{ name = "pytest" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/d1/b0/6b5337f9d59b26b0069ea3d5e863c31dc04b69e51bbfb1cf2ea6328fba87/pytest_rerunfailures-16.7.tar.gz", hash = "sha256:6956ddfb65ca1d07e7e3d99e2c5359d82300f4cb062e6049563bd2c106f72d5c", size = 59666, upload-time = "2026-09-17T07:08:48.871Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/ed/63/0114e45d4b2fcd5f6297dac655c067b47de28be4d33e088f200f0f2c4c28/pytest_rerunfailures-16.6.tar.gz", hash = "sha256:29dbfee46f542073c888e0ed4e81c51e15b9096f49a299eb1a759629c601684a", size = 42806, upload-time = "2026-08-17T07:11:00.447Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/c1/d3/07ea35102cf2020ddaaac368d2a6f0bcc63d6523fb8918805bac3eb8b98f/pytest_rerunfailures-16.7-py3-none-any.whl", hash = "sha256:edf1886209c2b7dafe35b5bf1708d6ec40ccf6c6b357f0f02807efcec0204c99", size = 23952, upload-time = "2026-09-17T07:08:47.635Z" },
+ { url = "https://files.pythonhosted.org/packages/5d/5e/1e994889673d7a0da11651f17ef789b6c83bfe349f29f871873dd3802445/pytest_rerunfailures-16.6-py3-none-any.whl", hash = "sha256:6af2d1ebd6e5cb79666ac408942cd6a0672a49fefd8523664770718560795e13", size = 19137, upload-time = "2026-08-17T07:10:59.121Z" },
]
[[package]]