-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add covering inputs as @example(...)
s in the code
#13
Comments
So if I understand correctly, the big-picture benefit is to work better with graceful degradation of By automatically providing those hard-coded cases in a form accessible to stub implementations of the (Besides working around any hassle with making the example database available everywhere, which to me seems better solved by providing a separate solution with great UX for hosting/distributing/syncing the example database.) |
Smoothly stepping down to a parametrized unit-test, yes. For some users (e.g. CPython) this is so that they can use a stub implementation; others might be happy to use Hypothesis' At scale, say 100+ people and 1M+ lines of code, it can be really important to have fast and deterministic CI because you're testing for regressions rather than bugs via that workflow above, and can run a separate bug-hunting program 'alongside' your CI system. Otherwise I agree that sharing the example database is almost always going to be a better and easier solution, via e.g. Hypothesis' |
Turns out that HypothesisWorks/hypothesis#3631 is a rather nice feature for Hypothesis itself, so we'll ship almost all the code upstream and HypoFuzz can just call into the hooks I left😁 |
OK, we've shipped all the upstreamable internals in Hypothesis - including removal of
|
Here's a neat workflow, combining the benefits for PBT and fuzzing with deterministic tests:
@example(...)
cases (this issue!)So what will it take to have automatically-maintained explicit examples? Some quick notes:
@example()
decorator, which rules out stateful tests or those usingst.data()
. We'll also have trouble with reprs that can't be eval'd back to an equivalent object - we might get a short distance by representing objects fromst.builds()
as the result of the call (also useful for Explaining failing examples - by showing which arguments (don't) matter HypothesisWorks/hypothesis#3411), but this seems like a fundamental limitation.LibCST
should make the latter pretty easy - we can construct a string call, attempt to parse it, and then insert it into the decorator list.<hash>.patch
file and the user doesgit apply ...
". We can dump the file on disk, and also make it downloadable from the dashboard for remote use. The patch shouldn't be too ugly, e.g. one line per arg, but users are expected to run their choice of autoformatter.This seems fiddly, but not actually that hard - we already report covering examples on the dashboard, after all. No timeline on when I'll get to this, but I'd be very happy to provide advice and code review to anyone interested in contributing 🙂
The text was updated successfully, but these errors were encountered: