This design constraint has been a recurring headache in Hypothesis. User provided functions must be treated as hazardous and can never be invoked outside the context of a test. This enables a lot of nice stuff for users, but it does rather tie our hands.
-
Show this thread
-
Anyway, long story short, the awful terrible solution was this: Hypothesis strategies at the time also had a serialised representation for their templates. They had to be able to validate this so as to not produce bad data when rerunning changed tests.
1 reply 0 retweets 1 likeShow this thread -
So a template for my_strat.flatmap(f) was a pair of a template for my_strat and a serialised representation that might or might not be convertible to a template, but you would only find out when the test ran. It was actually worse than that for reasons I won't get into.
1 reply 0 retweets 0 likesShow this thread -
This was dreadful and slow and buggy and caused all sorts of problems, but for the most part it worked, and it now meant something important: Hypothesis had a full end-to-end implementation of shrinking and serialisation that worked with anything you could randomly generate.
1 reply 0 retweets 0 likesShow this thread -
When writing the modern implementation of Hypothesis this gave me something very powerful: I knew that what I was trying to do was possible, because I already done it. The existing implementation was terrible, but I could focus on fixing that without worrying if it could work.
1 reply 0 retweets 3 likesShow this thread -
Remarkably little changed in the public API when I switched over from the old implementation to the new one. I had to remove a couple of really niche APIs that were no longer supportable (mostly things that made it look more QuickCheck like), but it was mostly fine.
1 reply 0 retweets 0 likesShow this thread -
Hypothesis has very much been a success story for writing a nice clean combinator based API that elides all of the underlying complexity of the implementation - I've been able to make some really invasive changes without users noticing anything except maybe some bugs.
1 reply 0 retweets 2 likesShow this thread -
One more FUN HYPOTHESIS FACT: Hypothesis is more monadic than QuickCheck in two senses. 1. Hypothesis strategies actually form a monad (they're parser combinators!), QuickCheck's Gen only "morally" does. 2. Everything in Hypothesis is in the monad, QC's shrinking isn't.
1 reply 0 retweets 5 likesShow this thread -
Despite this "monad(ic)" is mentioned exactly once in the Hypothesis docs. https://hypothesis.readthedocs.io/en/latest/data.html#chaining-strategies-together …
1 reply 0 retweets 3 likesShow this thread -
This thread is much longer than I intended, but people still seem entertained. As a breather, here's a photo of the unofficial Hypothesis mascot's tail being attacked by his brother Dexter (this would have been probably a bit before I left Google, so not quite Hypothesis era).pic.twitter.com/D0UuvyxNlb
3 replies 1 retweet 13 likesShow this thread
Your cat has an impressive bookshelf
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.