From 0b89e10c30c1431a0aa356016773a5b993ae0090 Mon Sep 17 00:00:00 2001 From: Peter Van Dyken Date: Wed, 29 Nov 2023 16:24:09 -0500 Subject: [PATCH] Switch to in-memory database for hypothesis A recent hypothesis release by default loads a directory based database of examples. This is incompatible with pyfakefs as hypothesis is unable to access the file system. Until a full workaround can be designed, we'll need to use the inmemory database --- snakebids/tests/conftest.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/snakebids/tests/conftest.py b/snakebids/tests/conftest.py index b9fcedc3..be0b6295 100644 --- a/snakebids/tests/conftest.py +++ b/snakebids/tests/conftest.py @@ -6,7 +6,7 @@ import bids.layout import pytest -from hypothesis import settings +from hypothesis import database, settings from pyfakefs.fake_filesystem import FakeFilesystem import snakebids.paths.resources as specs @@ -14,11 +14,18 @@ ## Hypothesis profiles +# TODO: The default Directory Database would be much better, but it's currently +# incompatible with pyfakefs. To fix it, we need to either patch @given or add +# another decorator that only activates the fake filesystem within the test body + # github-actions tends to have flaky runtimes, likely due to temporary slowdowns in the # runner, so just disable deadlines -settings.register_profile("pr", deadline=None) +settings.register_profile( + "pr", deadline=None, database=database.InMemoryExampleDatabase() +) +settings.register_profile("dev", database=database.InMemoryExampleDatabase()) -settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default")) +settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "dev")) # Fixtures