-
Notifications
You must be signed in to change notification settings - Fork 616
Add observation.metadata.choice_nodes
#4422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
2f636c9
a02dbac
2adab00
f63181b
26cffb2
70b2b8d
4de775f
bc163c2
0ca16a9
aa3b215
6dc159d
9c0f70e
82464d1
0d9e29b
1e744f1
076510d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RELEASE_TYPE: minor | ||
|
||
This release adds |OBSERVABILITY_CHOICE_NODES|, a new option for :ref:`observability <observability>`, which includes the choice sequence in ``metadata.choice_nodes`` for test case observations if set. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,15 @@ including Gson in Java, ``JSON.parse()`` in Ruby, and of course in Python. | |
:hide_key: /additionalProperties, /type | ||
|
||
|
||
Hypothesis Metadata | ||
^^^^^^^^^^^^^^^^^^^ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure sphinx has collapsible elements unless we install some third party extension 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a cute trick, the built-in .. only:: html
.. raw:: html
<details>
<summary>Click to expand</summary>
Put whatever you want here, and in the HTML build only it'll be inside a details tag!
.. only:: html
.. raw:: html
</details> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. happy to collapse for now, but TBH I think observability might deserve its own page at this point. (I think ghostwriter does as well). IMO a selling point of big api reference pages is that you don't have to worry about things like niche content or collapsing text
but still, collapsing makes it easy to miss, and this is a pretty important section for the right subset of people There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, good argument, leave it uncollapsed and we'll move it later. |
||
|
||
While the observability format is agnostic to the property-based testing library which generated it, Hypothesis includes specific values in the ``metadata`` key for test cases. You may rely on these being present if and only if the observation was generated by Hypothesis. | ||
|
||
.. jsonschema:: ./schema_metadata.json | ||
:hide_key: /additionalProperties, /type | ||
|
||
|
||
.. _pytest-plugin: | ||
|
||
The Hypothesis pytest plugin | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"title": "Hypothesis Metadata", | ||
tybug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"description": "Hypothesis-specific values included in the ``metadata`` key of observations for test cases.", | ||
"type": "object", | ||
"properties": { | ||
"traceback": { | ||
"type": ["string", "null"], | ||
"description": "The traceback for failing tests, if and only if ``status == \"failed\"``." | ||
}, | ||
"reproduction_decorator": { | ||
"type": ["string", "null"], | ||
"description": "The ``@reproduce_failure`` decorator string for failing tests, if and only if ``status == \"failed\"``." | ||
}, | ||
"predicates": { | ||
"type": "object", | ||
"description": "The number of times each |assume| and |@precondition| predicate was satisfied (``True``) and not satisfied (``False``).", | ||
"additionalProperties": { | ||
"type": "object", | ||
"properties": { | ||
"satisfied": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"description": "The number of times this predicate was satisfied (``True``)." | ||
}, | ||
"unsatisfied": { | ||
"type": "integer", | ||
"minimum": 0, | ||
"description": "The number of times this predicate was not satisfied (``False``)." | ||
} | ||
}, | ||
"required": ["satisfied", "unsatisfied"], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"backend": { | ||
"type": "object", | ||
"description": "Backend-specific observations from |PrimitiveProvider.observe_test_case| and |PrimitiveProvider.observe_information_messages|." | ||
}, | ||
"sys.argv": { | ||
"type": "array", | ||
"items": {"type": "string"}, | ||
"description": "The result of ``sys.argv``." | ||
}, | ||
"os.getpid()": { | ||
"type": "integer", | ||
"description": "The result of ``os.getpid()``." | ||
}, | ||
"imported_at": { | ||
"type": "number", | ||
"description": "The unix timestamp when Hypothesis was imported." | ||
}, | ||
"data_status": { | ||
"type": "number", | ||
"enum": [0, 1, 2, 3], | ||
"description": "The internal status of the ConjectureData for this test case. The values are as follows: ``Status.OVERRUN = 0``, ``Status.INVALID = 1``, ``Status.VALID = 2``, and ``Status.INTERESTING = 3``." | ||
}, | ||
"interesting_origin": { | ||
"type": ["string", "null"], | ||
"description": "The internal InterestingOrigin object for failing tests, if and only if ``status == \"failed\"``. The ``traceback`` string value is derived from this object." | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC we already store this in the top-level [goes and checks] aaaaaannnd, we mishandle non-failing cases, oops. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, INVALID and OVERRUN get collapsed together (which is probably-good as a library agnostic format) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I thought this was [e: and this means the type here is wrong, fixing..] [e2: nope, it is a string because we're documenting the file format here, not the in-memory format. Hmm, unfortunate that the two are similar but different...] |
||
"choice_nodes": { | ||
"type": ["array", "null"], | ||
"description": "The sequence of choices made during this test case. This includes the choice value, as well as its constraints and whether it was forced or not. The choice sequence is a relatively low-level implementation detail of Hypothesis, and is exposed here for users building tools or research on top of Hypothesis. See |PrimitiveProvider| for more details about the choice sequence.\n\nOnly present if |OBSERVABILITY_CHOICE_NODES| is set.", | ||
tybug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"enum": ["integer", "float", "string", "bytes", "boolean"], | ||
"description": "The type of choice made. Corresponds to a call to |PrimitiveProvider.draw_integer|, |PrimitiveProvider.draw_float|, |PrimitiveProvider.draw_string|, |PrimitiveProvider.draw_bytes|, or |PrimitiveProvider.draw_boolean|." | ||
}, | ||
"value": { | ||
"description": "The value of the choice. Corresponds to the value returned by a ``PrimitiveProvider.draw_*`` method.\n\n``NaN`` float values are returned as ``[\"float\", <float64_int_value>]``, to distinguish ``NaN`` floats with nonstandard bit patterns. Integers with ``abs(value) >= 2**63`` are returned as ``[\"integer\", str(value)]``, for compatibility with tools with integer size limitations. Bytes are returned as ``[\"bytes\", base64.b64encode(value)]``." | ||
}, | ||
"constraints": { | ||
"type": "object", | ||
"description": "The constraints for this choice. Corresponds to the constraints passed to a ``PrimitiveProvider.draw_*`` method. ``NaN`` float values, integers with ``abs(value) >= 2**63``, and byte values for constraints are transformed as for the ``value`` attribute." | ||
}, | ||
"was_forced": { | ||
"type": "boolean", | ||
"description": "Whether this choice was forced. As an implementation detail, Hypothesis occasionally requires that some choices take on a specific value, for instance to end generation of collection elements early for performance. These values are \"forced\", and have ``was_forced = True``." | ||
} | ||
}, | ||
"required": ["type", "value", "constraints", "was_forced"], | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"required": ["traceback", "reproduction_decorator", "predicates", "backend", "sys_argv", "os_getpid", "imported_at", "data_status", "interesting_origin", "choice_nodes"], | ||
"additionalProperties": false | ||
} |
Uh oh!
There was an error while loading. Please reload this page.