-
Notifications
You must be signed in to change notification settings - Fork 577
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
Generating test data without using @given decorator #3790
Comments
For determinism and number of examples, you'll want to use It's slower than plain Finally, I'll note that Hypothesis' data is draw from a really weird distribution, full of edge cases and weird correlations. That's great for finding bugs, but may or may not be what you want here - if not, I've heard good things about the |
Thanks for such a quick response, this helps! |
just to answer a concrete question... hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py Lines 327 to 340 in 226268c
|
What I want to achieve: I'm trying to use hypothesis to generate large amounts of randomized test data -- I'm not trying to use it for tests, just want to use in a script.
I found out that I can use
.example
method from a strategy to achieve data generation. I intentionally simplified my usecase, so let's say we want to generate 1000 integers:This works, however I have two issues
If I use custom code with
random.Random.randint
to generate 1000 integers, it completes instantly, as expected.If I use hypothesis via
@given
, defining the test, etc -- it also works instantly. But I don't really understand why is there such a performance difference?I tried using register_random, but it had no effect
So the questions are:
Apologies if it's not the best forum to ask -- I did read the docs and searched through the source code but couldn't really figure this out. Thanks!
The text was updated successfully, but these errors were encountered: