diff --git a/hypothesis-python/src/hypothesis/core.py b/hypothesis-python/src/hypothesis/core.py index 662c5f43c0..e000da174f 100644 --- a/hypothesis-python/src/hypothesis/core.py +++ b/hypothesis-python/src/hypothesis/core.py @@ -91,6 +91,7 @@ from hypothesis.internal.observability import ( OBSERVABILITY_COLLECT_COVERAGE, TESTCASE_CALLBACKS, + _system_metadata, deliver_json_blob, make_testcase, ) @@ -1066,7 +1067,6 @@ def _execute_once_for_engine(self, data: ConjectureData) -> None: string_repr=self._string_repr, arguments={**self._jsonable_arguments, **data._observability_args}, timing=self._timing_features, - metadata={}, coverage=tractable_coverage_report(trace) or None, ) deliver_json_blob(tc) @@ -1198,6 +1198,7 @@ def run_engine(self): "metadata": { "traceback": tb, "predicates": ran_example._observability_predicates, + **_system_metadata(), }, } deliver_json_blob(tc) diff --git a/hypothesis-python/src/hypothesis/internal/observability.py b/hypothesis-python/src/hypothesis/internal/observability.py index e389f54862..98753985f1 100644 --- a/hypothesis-python/src/hypothesis/internal/observability.py +++ b/hypothesis-python/src/hypothesis/internal/observability.py @@ -13,8 +13,10 @@ import json import os import sys +import time import warnings from datetime import date, timedelta +from functools import lru_cache from typing import Callable, Dict, List, Optional from hypothesis.configuration import storage_directory @@ -38,7 +40,6 @@ def make_testcase( string_repr: str = "", arguments: Optional[dict] = None, timing: Dict[str, float], - metadata: Optional[dict] = None, coverage: Optional[Dict[str, List[int]]] = None, ) -> dict: if data.interesting_origin: @@ -68,9 +69,9 @@ def make_testcase( }, "timing": timing, "metadata": { - **(metadata or {}), "traceback": getattr(data.extra_information, "_expected_traceback", None), "predicates": data._observability_predicates, + **_system_metadata(), }, "coverage": coverage, } @@ -88,6 +89,18 @@ def _deliver_to_file(value): # pragma: no cover f.write(json.dumps(value) + "\n") +_imported_at = time.time() + + +@lru_cache +def _system_metadata(): + return { + "sys.argv": sys.argv, + "os.getpid()": os.getpid(), + "imported_at": _imported_at, + } + + OBSERVABILITY_COLLECT_COVERAGE = ( "HYPOTHESIS_EXPERIMENTAL_OBSERVABILITY_NOCOVER" not in os.environ )