Skip to content

Commit c2e2c4e

Browse files
committed
address comments
1 parent c97d65a commit c2e2c4e

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
RELEASE_TYPE: patch
22

3-
This patch fixes a bug where only interactively-generated values (via ``data.draw``) would be reported in the ``arguments`` field of our :doc:`observability output <observability>`. Now, all values are reported.
3+
This patch fixes a bug since :ref:`v6.99.13` where only interactively-generated values (via ``data.draw``) would be reported in the ``arguments`` field of our :doc:`observability output <observability>`. Now, all values are reported.

hypothesis-python/src/hypothesis/internal/conjecture/data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,10 @@ def draw(
25312531
in_gctime = gc_cumulative_time() - gc_start_time
25322532
self.draw_times[key] = time.perf_counter() - start_time - in_gctime
25332533
except Exception as err:
2534-
add_note(err, f"while generating {key[9:]!r} from {strategy!r}")
2534+
add_note(
2535+
err,
2536+
f"while generating {key.removeprefix('generate:')!r} from {strategy!r}",
2537+
)
25352538
raise
25362539
if TESTCASE_CALLBACKS:
25372540
self._observability_args[key] = to_jsonable(v)

hypothesis-python/src/hypothesis/internal/observability.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def make_testcase(
6363
}[data.status],
6464
"status_reason": status_reason,
6565
"representation": string_repr,
66-
"arguments": arguments or {},
66+
"arguments": {
67+
k.removeprefix("generate:"): v for k, v in (arguments or {}).items()
68+
},
6769
"how_generated": how_generated, # iid, mutation, etc.
6870
"features": {
6971
**{

hypothesis-python/src/hypothesis/strategies/_internal/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,13 +2113,13 @@ def __repr__(self):
21132113
def draw(self, strategy: SearchStrategy[Ex], label: Any = None) -> Ex:
21142114
check_strategy(strategy, "strategy")
21152115
self.count += 1
2116-
printer = RepresentationPrinter(context=current_build_context())
21172116
desc = f"Draw {self.count}{'' if label is None else f' ({label})'}"
21182117
with deprecate_random_in_strategy("{}from {!r}", desc, strategy):
21192118
result = self.conjecture_data.draw(strategy, observe_as=f"generate:{desc}")
21202119

21212120
# optimization to avoid needless printer.pretty
21222121
if should_note():
2122+
printer = RepresentationPrinter(context=current_build_context())
21232123
printer.text(f"{desc}: ")
21242124
printer.pretty(result)
21252125
note(printer.getvalue())

hypothesis-python/tests/cover/test_observability.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def f(v1, v2, data):
8080
test_cases = [tc for tc in observations if tc["type"] == "test_case"]
8181
for test_case in test_cases:
8282
assert list(test_case["arguments"].keys()) == [
83-
"generate:v1",
84-
"generate:v2",
85-
"generate:data",
86-
"generate:Draw 1",
83+
"v1",
84+
"v2",
85+
"data",
86+
"Draw 1",
8787
], test_case
8888

8989

@@ -98,10 +98,10 @@ def f(named1, named2, data):
9898
test_cases = [tc for tc in observations if tc["type"] == "test_case"]
9999
for test_case in test_cases:
100100
assert list(test_case["arguments"].keys()) == [
101-
"generate:named1",
102-
"generate:named2",
103-
"generate:data",
104-
"generate:Draw 1",
101+
"named1",
102+
"named2",
103+
"data",
104+
"Draw 1",
105105
], test_case
106106

107107

0 commit comments

Comments
 (0)