Skip to content

Instantly share code, notes, and snippets.

@tomprince
Last active December 8, 2015 05:07
Show Gist options
  • Save tomprince/a560033e73d052274620 to your computer and use it in GitHub Desktop.
Save tomprince/a560033e73d052274620 to your computer and use it in GitHub Desktop.
from hypothesis.strategies import *
def subset_strat(strategies):
def build(keys):
return fixed_dictionaries({key: strategies[key] for key in keys})
return sets(sampled_from(strategies.keys())).flatmap(build)
if __name__ == "__main__":
print(subset_strat({"abc": integers(), "def": text()}).example())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment