Initial support for stateful testing#51
Conversation
src/hypofuzz/interface.py
Outdated
| # I guess it's conceivable this is possible...I just don't see how! | ||
| assert ( | ||
| extra_kw == {} | ||
| ), "Not possible for RuleBasedStateMachine.TestCase to be parametrized (we think?)" |
There was a problem hiding this comment.
Correct, because Hypothesis is responsible for creating the TestCase object, and we don't require Pytest - so it can't need parameters filled in.
|
This will be very nice to have, and the Hypothesis-side refactoring looks good to me too (with one note above). |
|
will look to merge this after #53; the timing of the hypothesis-side releases means we need compatibility with bufferless hypothesis first |
|
Error only in pytest 7 🤔 will have to figure out what pytest internals changed here |
|
I gave up because 1) this seems like it could be a rabbit hole to track down, and 2) the requirements to trigger this are rare (pytest 7 + stateful + custom database) |
| # runTest is a function, not a bound method, under pyest7. | ||
| # I wonder if something about TestCase instantiation order | ||
| # changed in pytest 8? Either way, we can't access | ||
| # __self__.settings uder pytest 7. | ||
| # | ||
| # I am going to call this an acceptably rare bug for now, | ||
| # because it should only manifest if the user sets a custom | ||
| # database on a stateful test under pytest 7 (all non-db | ||
| # settings are ignored by hypofuzz). | ||
| settings=runTest.__self__.settings if pytest8 else None, |
There was a problem hiding this comment.
Ugh, I really don't like this but I think it's probably the best option we practically have.
In the medium term, I'd like us to track all the tests-we-don't-collect, and have a dashboard page which lists them and explains why each was skipped (as well as optional terminal reporting? hmm).
There was a problem hiding this comment.
yup I'd like that as well, should be doable nearish term. (our dashboard will probably turn into the standard "sidebar on the left which lists pages", and one page is a test overview or similar).
I will come back to this bug at some point, there are just many better things to do in the meantime!
There was a problem hiding this comment.
I think I found the relevant pytest change: pytest-dev/pytest#12089 (since pytest 8.2.0). unsure if a fix will be easy
There was a problem hiding this comment.
let's make sure we pick frameworks etc which can be responsive / mobile-friendly; the dominant usecase will be on localhost but scaling beyond that is a goal.
Closes #38. Depends on #50 for a clean merge.
This requires a small amount of refactoring Hypothesis-side, including setting a new
runTest._hypothesis_state_machine_class = clsattribute. I don't have a great grasp of the stateful testing internals, so I may be overcomplicating things? It seems that what Hypofuzz really wants to access is the underlying@givenwhich drives stateful test - and to get to that we need to rejig some code.Here's the Hypothesis-side companion diff, which I can PR to Hypothesis: