Given a regexp, I would like to generate random data x number of time to test something.
e.g.
>>> print generate_date('\d{2,3}')
13
>>> print generate_date('\d{2,3}')
422
Of course the objective is to do something a bit more complicated than that such as phone numbers and email addresses.
Does something like this exists? If it does, does it exists for Python? If not, any clue/theory I could use to do that?
Pyparsing includes this regex inverter, which returns a generator of all permutations for simple regexes. Here are some of the test cases from that module:
Edit:
To do your random selection, create a list (once!) of your permutations, and then call
random.choiceon the list each time you want a random string that matches the regex, something like this (untested):