|
101 | 101 | from hypothesis.internal.observability import (
|
102 | 102 | OBSERVABILITY_COLLECT_COVERAGE,
|
103 | 103 | TESTCASE_CALLBACKS,
|
104 |
| - _system_metadata, |
105 |
| - deliver_json_blob, |
| 104 | + InfoObservation, |
| 105 | + InfoObservationType, |
| 106 | + deliver_observation, |
106 | 107 | make_testcase,
|
107 | 108 | )
|
108 | 109 | from hypothesis.internal.reflection import (
|
@@ -613,14 +614,14 @@ def execute_explicit_examples(state, wrapped_test, arguments, kwargs, original_s
|
613 | 614 | )
|
614 | 615 |
|
615 | 616 | tc = make_testcase(
|
616 |
| - start_timestamp=state._start_timestamp, |
617 |
| - test_name_or_nodeid=state.test_identifier, |
| 617 | + run_start=state._start_timestamp, |
| 618 | + property=state.test_identifier, |
618 | 619 | data=empty_data,
|
619 | 620 | how_generated="explicit example",
|
620 |
| - string_repr=state._string_repr, |
| 621 | + representation=state._string_repr, |
621 | 622 | timing=state._timing_features,
|
622 | 623 | )
|
623 |
| - deliver_json_blob(tc) |
| 624 | + deliver_observation(tc) |
624 | 625 |
|
625 | 626 | if fragments_reported:
|
626 | 627 | verbose_report(fragments_reported[0].replace("Falsifying", "Trying", 1))
|
@@ -1225,35 +1226,35 @@ def _execute_once_for_engine(self, data: ConjectureData) -> None:
|
1225 | 1226 | self._string_repr = "<backend failed to realize symbolic arguments>"
|
1226 | 1227 |
|
1227 | 1228 | tc = make_testcase(
|
1228 |
| - start_timestamp=self._start_timestamp, |
1229 |
| - test_name_or_nodeid=self.test_identifier, |
| 1229 | + run_start=self._start_timestamp, |
| 1230 | + property=self.test_identifier, |
1230 | 1231 | data=data,
|
1231 | 1232 | how_generated=f"during {phase} phase{backend_desc}",
|
1232 |
| - string_repr=self._string_repr, |
| 1233 | + representation=self._string_repr, |
1233 | 1234 | arguments=data._observability_args,
|
1234 | 1235 | timing=self._timing_features,
|
1235 | 1236 | coverage=tractable_coverage_report(trace) or None,
|
1236 | 1237 | phase=phase,
|
1237 | 1238 | backend_metadata=data.provider.observe_test_case(),
|
1238 | 1239 | )
|
1239 |
| - deliver_json_blob(tc) |
| 1240 | + deliver_observation(tc) |
1240 | 1241 | for msg in data.provider.observe_information_messages(
|
1241 | 1242 | lifetime="test_case"
|
1242 | 1243 | ):
|
1243 | 1244 | self._deliver_information_message(**msg)
|
1244 | 1245 | self._timing_features = {}
|
1245 | 1246 |
|
1246 | 1247 | def _deliver_information_message(
|
1247 |
| - self, *, type: str, title: str, content: Union[str, dict] |
| 1248 | + self, *, type: InfoObservationType, title: str, content: Union[str, dict] |
1248 | 1249 | ) -> None:
|
1249 |
| - deliver_json_blob( |
1250 |
| - { |
1251 |
| - "type": type, |
1252 |
| - "run_start": self._start_timestamp, |
1253 |
| - "property": self.test_identifier, |
1254 |
| - "title": title, |
1255 |
| - "content": content, |
1256 |
| - } |
| 1250 | + deliver_observation( |
| 1251 | + InfoObservation( |
| 1252 | + type=type, |
| 1253 | + run_start=self._start_timestamp, |
| 1254 | + property=self.test_identifier, |
| 1255 | + title=title, |
| 1256 | + content=content, |
| 1257 | + ) |
1257 | 1258 | )
|
1258 | 1259 |
|
1259 | 1260 | def run_engine(self):
|
@@ -1421,31 +1422,20 @@ def run_engine(self):
|
1421 | 1422 | raise NotImplementedError("This should be unreachable")
|
1422 | 1423 | finally:
|
1423 | 1424 | # log our observability line for the final failing example
|
1424 |
| - tc = { |
1425 |
| - "type": "test_case", |
1426 |
| - "run_start": self._start_timestamp, |
1427 |
| - "property": self.test_identifier, |
1428 |
| - "status": "passed" if sys.exc_info()[0] else "failed", |
1429 |
| - "status_reason": str(origin or "unexpected/flaky pass"), |
1430 |
| - "representation": self._string_repr, |
1431 |
| - "arguments": ran_example._observability_args, |
1432 |
| - "how_generated": "minimal failing example", |
1433 |
| - "features": { |
1434 |
| - **{ |
1435 |
| - f"target:{k}".strip(":"): v |
1436 |
| - for k, v in ran_example.target_observations.items() |
1437 |
| - }, |
1438 |
| - **ran_example.events, |
1439 |
| - }, |
1440 |
| - "timing": self._timing_features, |
1441 |
| - "coverage": None, # Not recorded when we're replaying the MFE |
1442 |
| - "metadata": { |
1443 |
| - "traceback": tb, |
1444 |
| - "predicates": dict(ran_example._observability_predicates), |
1445 |
| - **_system_metadata(), |
1446 |
| - }, |
1447 |
| - } |
1448 |
| - deliver_json_blob(tc) |
| 1425 | + tc = make_testcase( |
| 1426 | + run_start=self._start_timestamp, |
| 1427 | + property=self.test_identifier, |
| 1428 | + data=ran_example, |
| 1429 | + how_generated="minimal failing example", |
| 1430 | + representation=self._string_repr, |
| 1431 | + arguments=ran_example._observability_args, |
| 1432 | + timing=self._timing_features, |
| 1433 | + coverage=None, # Not recorded when we're replaying the MFE |
| 1434 | + status="passed" if sys.exc_info()[0] else "failed", |
| 1435 | + status_reason=str(origin or "unexpected/flaky pass"), |
| 1436 | + metadata={"traceback": tb}, |
| 1437 | + ) |
| 1438 | + deliver_observation(tc) |
1449 | 1439 | # Whether or not replay actually raised the exception again, we want
|
1450 | 1440 | # to print the reproduce_failure decorator for the failing example.
|
1451 | 1441 | if self.settings.print_blob:
|
|
0 commit comments