def test_overflow(self): generator = util.unique(g.Choice(choices=(1, 2, 3))) generator() generator() generator() self.assertRaises(UniqueValueTimeoutError, generator)
def __init__(self): if self.unique: self.generator = util.unique( fn=self.generator, depth_limit=self.depth_limit, key_fn=self.key_fn, seen=self.seen, )
def test_is_pretty_unique(self): # This is not the most scientific way to test it, but we have slightly # more than 400 usernames, if we generate 400 unique usernames 1000 # times, it is probably likely that this works. for i in xrange(1000): unique_username = util.unique(g.username) seen = set() for i in xrange(400): username = unique_username() self.assertNotIn(username, seen) seen.add(username)
def test_is_pretty_unique(self): # This is not the most scientific way to test it, but we have slightly # more than 400 usernames, if we generate 400 unique usernames 1000 # times, it is probably likely that this works. for i in xrange(1000): unique_username = util.unique(g.username) seen = set() for i in xrange(400): username = unique_username() assert username not in seen seen.add(username)
def test_composability(self): for i in xrange(1000): unique_usernames = util.unique(g.username) many_unique_usernames = util.times(unique_usernames, 400) seen = set() count = 0 for username in many_unique_usernames: count += 1 self.assertNotIn(username, seen) seen.add(username) assert count == 400
def test_composability(self): for i in xrange(1000): unique_usernames = util.unique(g.username) many_unique_usernames = util.times(unique_usernames, 400) seen = set() count = 0 for username in many_unique_usernames: count += 1 assert username not in seen seen.add(username) assert count == 400