Skip to content
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

Limited string size sample #95

Closed
aplastiras opened this issue Mar 9, 2022 · 1 comment
Closed

Limited string size sample #95

aplastiras opened this issue Mar 9, 2022 · 1 comment

Comments

@aplastiras
Copy link

aplastiras commented Mar 9, 2022

Hi,

I am using hypothesis-jsonschema to generate test sample data :

I am using custom_formats for string data as shown below:

size_values = []

@settings(max_examples=10000)
@given(from_schema({"type": "string",
                    "format": "card",
                    "maxLength": 1000},
                   custom_formats={'card': text(printable)},))
def generate_samples(data):
    size_values.append(len(data))
    pprint([data, len(data)])
generate_samples()

print('Max sample length: %d'%max(size_values))
...
['KJK gh', 6]
['KXA', 3]
['KAA', 3]
['KKA', 3]
['p?0', 3]
['??0', 3]
['?00', 3]
['?0?', 3]
['00?', 3]
['00?0Q\rer', 8]
Max sample length: 46

The issue is that by having set maxLength = 1000 as part of json schema the generated strings have size 40-60 characters max even after generating 10000 samples.

Is there any configuration I am missing that is restricting the size of the string?
How can I stress the string size to its limit?

Thank you in advance
Apostolos

@aplastiras aplastiras changed the title Limited string length sample Limited string size sample Mar 9, 2022
@Zac-HD
Copy link
Member

Zac-HD commented Mar 9, 2022

This is a result of Hypothesis' underlying design, and unfixable without making it radically less effective at finding bugs on realistic problems with eg nested schemas. There's also no config that would touch this; the internal average_size param is, well, internal.

So my advice is the remarkably unhelpful "don't worry about it, it's fine" 😕

@Zac-HD Zac-HD closed this as completed Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants