scipy/acceptable_failure_rate.patch
Miro Hrončok 6ac9ed170a acceptable_failure_rate.patch: Don't use pytest private API
The private API used here was removed in pytest 5.
There is a public API now, pytest.ExitCode.TESTS_FAILED,
however that is not yet available in pytest 4.

We hardcode the value 1 instead, it is unlikely to be changed.
Once pytest 4 is gone, we can switch to the new API.

See https://github.com/pytest-dev/pytest/issues/5125
2020-01-02 16:22:28 +01:00

21 lines
729 B
Diff

diff --git a/scipy/conftest.py b/scipy/conftest.py
index e5fac23..1a971e8 100644
--- a/scipy/conftest.py
+++ b/scipy/conftest.py
@@ -37,3 +38,15 @@ def check_fpu_mode(request):
warnings.warn("FPU mode changed from {0:#x} to {1:#x} during "
"the test".format(old_mode, new_mode),
category=FPUModeChangeWarning, stacklevel=0)
+
+
+ACCEPTABLE_FAILURE_RATE = int(os.environ.get('ACCEPTABLE_FAILURE_RATE', 0))
+
+
+@pytest.hookimpl()
+def pytest_sessionfinish(session, exitstatus):
+ if exitstatus != 1:
+ return
+ failure_rate = (100.0 * session.testsfailed) / session.testscollected
+ if failure_rate <= ACCEPTABLE_FAILURE_RATE:
+ session.exitstatus = 0