This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Zac Hatfield-Dodds
Recipients Zac Hatfield-Dodds, meador.inge, terry.reedy
Date 2020-10-24.00:58:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603501127.27.0.692198969027.issue38953@roundup.psfhosted.org>
In-reply-to
Content
Thanks for your comments Terry - I'm delighted that it's useful.  It's been a while since I wrote that, and entirely possible that it's just a typo.

Hypothesis does indeed support unittest, including for multiple-failure reporting and so on. 
 You can see my unittest implementation of the tokenise tests at https://github.com/Zac-HD/stdlib-property-tests/blob/b5ef97f9e7fd1b0e7a028823e436f78f374cf0dc/tests/test_source_code.py#L87-L133

Subtests are a little tricky, because the default interaction is to store the subtests for *all* test cases generated by Hypothesis.  We therefore monkeypatch it to a no-op, but more sophisticated handling is almost certainly possible.  More generally, when using Hypothesis I would usually ask @given for single inputs and call the test method; which replaces the usual loop over a list of inputs with subTest.

An iterator interface is not available because in general (see e.g. `hypothesis.strategies.data()` or stateful testing) it is not possible to separate data generation from test execution, and also because Hypothesis uses feedback from previous inputs in deciding what to generate.  Instead of "for testcase in testcases: with subTest: ...", I'd write "@given(testcase=...) def test_foo(self, testcase): ...".


I've sent you an email for the other conversation.  (anyone else interested is invited to get in touch via zhd.dev :-))
History
Date User Action Args
2020-10-24 00:58:47Zac Hatfield-Doddssetrecipients: + Zac Hatfield-Dodds, terry.reedy, meador.inge
2020-10-24 00:58:47Zac Hatfield-Doddssetmessageid: <1603501127.27.0.692198969027.issue38953@roundup.psfhosted.org>
2020-10-24 00:58:47Zac Hatfield-Doddslinkissue38953 messages
2020-10-24 00:58:46Zac Hatfield-Doddscreate