Custom Input Help

10 views
Skip to first unread message

Bryan Xu

unread,
May 29, 2022, 2:51:30 AM5/29/22
to Hypothesis users
Hi there!

I'm quite new to the library (also a student so I may have missed obvious things), but I was wondering if there were ways to add certain constraints to the input generation. As a note, I am currently more focused on the input generation more than the testing applications. In particular, I have a "maze" object that looks like this: 

maze = [
['+','+','+','+','+','+'],
['+',' ','+',' ',' ','G'],
['+',' ',' ',' ','+','+'],
['+',' ','+','+',' ','+'],
['+',' ',' ',' ',' ','+'],
['+','+','+','+','+','+'] ]

where each maze element can have one of three states: ' ' - an empty space, '+' - a wall, 'G' - a goal. 

I currently have: 
lists(lists(from_regex(regex = '^[ g+]{1}$', fullmatch=True), min_size=5, max_size=5), min_size=5, max_size=5)

but this gives me an output that looks like:
[['g', 'g', 'g', 'g', 'g'], ['g', 'g', 'g', 'g', 'g'], ['g', 'g', 'g', 'g', 'g'], ['g', 'g', 'g', 'g', 'g'], ['g', 'g', 'g', 'g', 'g']]

My first constraint that I would like it to have would be that only one 'g' is generated per maze generation. Secondly, I would like to have more variations in output. When I get the max_examples to 5, 4/5 are the exact same (as the example output from above). I'm not quite sure if the library is able to be used specifically for input generation, so any advice is appreciated! 

Reply all
Reply to author
Forward
0 new messages