Skip to content

Document is_hypothesis_test#4354

Merged
Liam-DeVoe merged 3 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:document-is-hypothesis-test
Apr 10, 2025
Merged

Document is_hypothesis_test#4354
Liam-DeVoe merged 3 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:document-is-hypothesis-test

Conversation

@Liam-DeVoe
Copy link
Copy Markdown
Member

Because this has a code interface, I put it in the API reference, instead of the Integrations reference.

Comment on lines +1020 to +1021
To determine whether a test has been defined with Hypothesis or not, use |is_hypothesis_test|:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want to add a note: if you're working with pytest, our [pytest plugin] automatically marks all such tests, so you can use node.get_closest_marker("hypothesis") rather than digging down to the callable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a not-found error:

:func:`node.get_closest_marker("hypothesis") <pytest:_pytest.nodes.Node.get_closest_marker>`

despite:

 ~/Desktop λ python -m sphinx.ext.intersphinx https://docs.pytest.org/en/stable/objects.inv | grep get_closest_marker
    _pytest.nodes.Node.get_closest_marker                                            : reference/reference.html#pytest.nodes.Node.get_closest_marker
 ~/Desktop λ 

and I gave up after 10 minutes, so no nice get_closest_marker link :(

.. |BackgroundWriteDatabase| replace:: :class:`~hypothesis.database.BackgroundWriteDatabase`
.. |RedisExampleDatabase| replace:: :class:`~hypothesis.extra.redis.RedisExampleDatabase`

.. |is_hypothesis_test| replace:: :func:`~hypothesis.is_hypothesis_test`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case I'd just inline the target definition here, since we're not referring it that often and it's not that much longer without custom link text. Does seem to be somewhere where we just have diverging taste though, and I don't mind you going with yours!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought process is that in the future I don't want to have to think about what sphinx role to use (remember if it's called func or method), forget the tilde, etc. Maybe a skill issue on my end? I'm happy to admit this might be a personal crutch and that we shouldn't have a goal of |-references for every possible hypothesis object, though I weakly think it's a good thing.

@Liam-DeVoe Liam-DeVoe enabled auto-merge April 10, 2025 03:49
@Liam-DeVoe Liam-DeVoe merged commit 83c5da4 into HypothesisWorks:master Apr 10, 2025
60 checks passed
@Liam-DeVoe Liam-DeVoe deleted the document-is-hypothesis-test branch April 10, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants