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