lycantropos / hypothesis_sqlalchemy

hypothesis strategies for generating SQLAlchemy objects
MIT License
28 stars 8 forks source link

Allow application of extra functions to strategy in lists_factory #25

Open rubenhelsloot opened 4 years ago

rubenhelsloot commented 4 years ago

I often generate lists of models using the lists_factory in hypothesis_sqlalchemy.tabular.records, but sometimes I have the issue that I need to apply a filter function to each generated model. For example, I have a model that has always one of three foreign keys set, so I want to filter out all examples where this is not the case. However, if I apply .filter to the entire list of generated models, hypothesis will take a very long time to figure out what is wrong and what to avoid, so I'd rather just filter out those specific examples that violate the constraint, while maintaining replayability.

Would it be possible to allow lists_factory to accept a function that is then applied to each individual values_tuples pair it generates?

lycantropos commented 4 years ago

I'm not sure I understand the problem, can you please provide minimal reproducible example?