Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172"""Hypothesis under the repository's seed and budget convention.
Importing this module registers two settings profiles and loads one(robot-docs/testing.md#seeds-and-budgets):
- ``gate``, when ``ALBEDO_PROPERTY_SEED`` is unset: derandomized, so every run tries the same examples, with no example database.- ``discovery``, when it is ``random`` or an integer: fresh examples, and failures kept in an example database under the scratch root (``$ALBEDO_TEST_TMP/hypothesis``), never in the tree. An integer seed replays exactly that run.
``ALBEDO_PROPERTY_CASES`` sets ``max_examples``. A test that needs a smallergate budget passes ``@settings(max_examples=cases(n))``, which the variablestill overrides. Both profiles print the reproduction blob with the shrunkexample, and a random run prints its ``@seed``, so the log alone reproduces afailure. Commit each shrunk counterexample as a named example test."""
import osfrom pathlib import Path
from hypothesis import core, settingsfrom hypothesis.database import DirectoryBasedExampleDatabase
GATE_CASES = 100DISCOVERY_CASES = 2000ROOT = Path(os.environ.get("ALBEDO_TEST_TMP", "/tmp/albedo-tests"))
def cases(gate: int) -> int: """A test's example budget: ``gate`` unless ``ALBEDO_PROPERTY_CASES`` is set.""" value = os.environ.get("ALBEDO_PROPERTY_CASES") return int(value) if value else gate
def _load() -> str: seed = os.environ.get("ALBEDO_PROPERTY_SEED", "") common = settings(deadline=None, print_blob=True) settings.register_profile( "gate", derandomize=True, database=None, max_examples=cases(GATE_CASES), parent=common, ) settings.register_profile( "discovery", derandomize=False, database=DirectoryBasedExampleDatabase(ROOT / "hypothesis"), max_examples=cases(DISCOVERY_CASES), parent=common, ) if seed == "": profile = "gate" elif seed == "random": profile = "discovery" elif seed.isdigit(): profile = "discovery" # What `pytest --hypothesis-seed` sets. Hypothesis reads no seed from # the environment, and a forced seed skips the example database. setattr(core, "global_force_seed", int(seed)) else: raise ValueError( "ALBEDO_PROPERTY_SEED must be unset, 'random', or a non-negative integer" ) settings.load_profile(profile) return profile
PROFILE = _load()