From 65f8935314a27a21a908e28c0c7f422acb379889 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Wed, 21 Aug 2019 09:37:08 -0400
Subject: [PATCH] Create a `ci` profile and select it.

---
 .circleci/config.yml                  |  1 +
 src/_zkapauthorizer/tests/__init__.py | 31 +++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index b367ad7..6ad5add 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -53,6 +53,7 @@ jobs:
 
     environment:
       PIP_SYNC_REQUIREMENTS: "requirements.txt requirements-tests.txt"
+      ZKAPAUTHORIZER_HYPOTHESIS_PROFILE: "ci"
 
     steps:
       - "checkout"
diff --git a/src/_zkapauthorizer/tests/__init__.py b/src/_zkapauthorizer/tests/__init__.py
index ddc6757..5019fa0 100644
--- a/src/_zkapauthorizer/tests/__init__.py
+++ b/src/_zkapauthorizer/tests/__init__.py
@@ -15,3 +15,34 @@
 """
 The automated unit test suite.
 """
+
+def _configure_hypothesis():
+    """
+    Select define Hypothesis profiles and select one based on environment
+    variables.
+    """
+    from os import environ
+
+    from hypothesis import (
+        HealthCheck,
+        settings,
+    )
+
+    settings.register_profile(
+        "ci",
+        suppress_health_check=[
+            # CPU resources available to CI builds typically varies
+            # significantly from run to run making it difficult to determine
+            # if "too slow" data generation is a result of the code or the
+            # execution environment.  Prevent these checks from
+            # (intermittently) failing tests that are otherwise fine.
+            HealthCheck.too_slow,
+        ],
+        # With the same reasoning, disable the test deadline.
+        deadline=None,
+    )
+
+    profile_name = environ.get("ZKAPAUTHORIZER_HYPOTHESIS_PROFILE", "default")
+    settings.load_profile(profile_name)
+
+_configure_hypothesis()
-- 
GitLab