Ejemplo n.º 1
0
    def test_overflow(self):
        generator = util.unique(g.Choice(choices=(1, 2, 3)))

        generator()
        generator()
        generator()

        self.assertRaises(UniqueValueTimeoutError, generator)
Ejemplo n.º 2
0
 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,
         )
Ejemplo n.º 3
0
 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,
                 )
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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