Skip to content

Commit

Permalink
Switch to in-memory database for hypothesis
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pvandyken committed Nov 29, 2023
1 parent a2cb323 commit 0b89e10
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions snakebids/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@

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
from snakebids import resources

## 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

Expand Down

0 comments on commit 0b89e10

Please sign in to comment.