test_generators testresult

cpu-mhz 1603.696
cpu-model AMD Opteron(tm) Processor 242
executable py.py
execution-time 428.934123039
exit-status 0
fspath /home/hpk/pypy-dist/lib-python/modified-2.4.1/test/test_generators.py
options corethread_weakref
outcome OK
platform linux2
pypy-revision 29280
python-version-info (2, 4, 2, 'final', 0)
startdate Fri Jun 23 21:22:17 2006
testreport-version 1.1
timeout 1444.0
userhost hpk@cen01

stdout

Trying:
    def f():
       yield 1
       yield 2
Expecting nothing
ok
Trying:
    for i in f():
        print i
Expecting:
    1
    2
ok
Trying:
    g = f()
Expecting nothing
ok
Trying:
    g.next()
Expecting:
    1
ok
Trying:
    g.next()
Expecting:
    2
ok
Trying:
    g.next()
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "<stdin>", line 2, in g
    StopIteration
ok
Trying:
    def f():
        yield 1
        return
        yield 2 # never reached
Expecting nothing
ok
Trying:
    g = f()
Expecting nothing
ok
Trying:
    g.next()
Expecting:
    1
ok
Trying:
    g.next()
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "<stdin>", line 3, in f
    StopIteration
ok
Trying:
    g.next() # once stopped, can't be resumed
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    StopIteration
ok
Trying:
    def f():
        yield 1
        raise StopIteration
        yield 2 # never reached
Expecting nothing
ok
Trying:
    g = f()
Expecting nothing
ok
Trying:
    g.next()
Expecting:
    1
ok
Trying:
    g.next()
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    StopIteration
ok
Trying:
    g.next()
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    StopIteration
ok
Trying:
    def g1():
        try:
            return
        except:
            yield 1
Expecting nothing
ok
Trying:
    list(g1())
Expecting:
    []
ok
Trying:
    def g2():
        try:
            raise StopIteration
        except:
            yield 42
Expecting nothing
ok
Trying:
    print list(g2())
Expecting:
    [42]
ok
Trying:
    def g3():
        try:
            return
        finally:
            yield 1
Expecting nothing
ok
Trying:
    list(g3())
Expecting:
    [1]
ok
Trying:
    def yrange(n):
        for i in range(n):
            yield i
Expecting nothing
ok
Trying:
    list(yrange(5))
Expecting:
    [0, 1, 2, 3, 4]
ok
Trying:
    def creator():
        r = yrange(5)
        print "creator", r.next()
        return r
Expecting nothing
ok
Trying:
    def caller():
        r = creator()
        for i in r:
                print "caller", i
Expecting nothing
ok
Trying:
    caller()
Expecting:
    creator 0
    caller 1
    caller 2
    caller 3
    caller 4
ok
Trying:
    def zrange(n):
        for i in yrange(n):
            yield i
Expecting nothing
ok
Trying:
    list(zrange(5))
Expecting:
    [0, 1, 2, 3, 4]
ok
Trying:
    for c in conjoin([lambda: iter((0, 1))] * 3):
        print c
Expecting:
    [0, 0, 0]
    [0, 0, 1]
    [0, 1, 0]
    [0, 1, 1]
    [1, 0, 0]
    [1, 0, 1]
    [1, 1, 0]
    [1, 1, 1]
ok
Trying:
    def gencopy(iterator):
        for x in iterator:
            yield x[:]
Expecting nothing
ok
Trying:
    for n in range(10):
        all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
        print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
Expecting:
    0 1 True True
    1 2 True True
    2 4 True True
    3 8 True True
    4 16 True True
    5 32 True True
    6 64 True True
    7 128 True True
    8 256 True True
    9 512 True True
ok
Trying:
    q = Queens(8)
Expecting nothing
ok
Trying:
    LIMIT = 2
Expecting nothing
ok
Trying:
    count = 0
Expecting nothing
ok
Trying:
    for row2col in q.solve():
        count += 1
        if count <= LIMIT:
            print "Solution", count
            q.printsolution(row2col)
Expecting:
    Solution 1
    +-+-+-+-+-+-+-+-+
    |Q| | | | | | | |
    +-+-+-+-+-+-+-+-+
    | | | | |Q| | | |
    +-+-+-+-+-+-+-+-+
    | | | | | | | |Q|
    +-+-+-+-+-+-+-+-+
    | | | | | |Q| | |
    +-+-+-+-+-+-+-+-+
    | | |Q| | | | | |
    +-+-+-+-+-+-+-+-+
    | | | | | | |Q| |
    +-+-+-+-+-+-+-+-+
    | |Q| | | | | | |
    +-+-+-+-+-+-+-+-+
    | | | |Q| | | | |
    +-+-+-+-+-+-+-+-+
    Solution 2
    +-+-+-+-+-+-+-+-+
    |Q| | | | | | | |
    +-+-+-+-+-+-+-+-+
    | | | | | |Q| | |
    +-+-+-+-+-+-+-+-+
    | | | | | | | |Q|
    +-+-+-+-+-+-+-+-+
    | | |Q| | | | | |
    +-+-+-+-+-+-+-+-+
    | | | | | | |Q| |
    +-+-+-+-+-+-+-+-+
    | | | |Q| | | | |
    +-+-+-+-+-+-+-+-+
    | |Q| | | | | | |
    +-+-+-+-+-+-+-+-+
    | | | | |Q| | | |
    +-+-+-+-+-+-+-+-+
ok
Trying:
    print count, "solutions in all."
Expecting:
    92 solutions in all.
ok
Trying:
    k = Knights(10, 10)
Expecting nothing
ok
Trying:
    LIMIT = 2
Expecting nothing
ok
Trying:
    count = 0
Expecting nothing
ok
Trying:
    for x in k.solve():
        count += 1
        if count <= LIMIT:
            print "Solution", count
            k.printsolution(x)
        else:
            break
Expecting:
    Solution 1
    +---+---+---+---+---+---+---+---+---+---+
    |  1| 58| 27| 34|  3| 40| 29| 10|  5|  8|
    +---+---+---+---+---+---+---+---+---+---+
    | 26| 35|  2| 57| 28| 33|  4|  7| 30| 11|
    +---+---+---+---+---+---+---+---+---+---+
    | 59|100| 73| 36| 41| 56| 39| 32|  9|  6|
    +---+---+---+---+---+---+---+---+---+---+
    | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31|
    +---+---+---+---+---+---+---+---+---+---+
    | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50|
    +---+---+---+---+---+---+---+---+---+---+
    | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13|
    +---+---+---+---+---+---+---+---+---+---+
    | 87| 98| 91| 80| 77| 84| 53| 46| 65| 44|
    +---+---+---+---+---+---+---+---+---+---+
    | 90| 23| 88| 95| 70| 79| 68| 83| 14| 17|
    +---+---+---+---+---+---+---+---+---+---+
    | 97| 92| 21| 78| 81| 94| 19| 16| 45| 66|
    +---+---+---+---+---+---+---+---+---+---+
    | 22| 89| 96| 93| 20| 69| 82| 67| 18| 15|
    +---+---+---+---+---+---+---+---+---+---+
    Solution 2
    +---+---+---+---+---+---+---+---+---+---+
    |  1| 58| 27| 34|  3| 40| 29| 10|  5|  8|
    +---+---+---+---+---+---+---+---+---+---+
    | 26| 35|  2| 57| 28| 33|  4|  7| 30| 11|
    +---+---+---+---+---+---+---+---+---+---+
    | 59|100| 73| 36| 41| 56| 39| 32|  9|  6|
    +---+---+---+---+---+---+---+---+---+---+
    | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31|
    +---+---+---+---+---+---+---+---+---+---+
    | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50|
    +---+---+---+---+---+---+---+---+---+---+
    | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13|
    +---+---+---+---+---+---+---+---+---+---+
    | 87| 98| 89| 80| 77| 84| 53| 46| 65| 44|
    +---+---+---+---+---+---+---+---+---+---+
    | 90| 23| 92| 95| 70| 79| 68| 83| 14| 17|
    +---+---+---+---+---+---+---+---+---+---+
    | 97| 88| 21| 78| 81| 94| 19| 16| 45| 66|
    +---+---+---+---+---+---+---+---+---+---+
    | 22| 91| 96| 93| 20| 69| 82| 67| 18| 15|
    +---+---+---+---+---+---+---+---+---+---+
ok
Trying:
    def g():
        i = me.next()
        yield i
Expecting nothing
ok
Trying:
    me = g()
Expecting nothing
ok
Trying:
    me.next()
Expecting:
    Traceback (most recent call last):
     ...
      File "<string>", line 2, in g
    ValueError: generator already executing
ok
Trying:
    def f1():
        try:
            return
        except:
           yield 1
Expecting nothing
ok
Trying:
    print list(f1())
Expecting:
    []
ok
Trying:
    def f2():
        try:
            raise StopIteration
        except:
            yield 42
Expecting nothing
ok
Trying:
    print list(f2())
Expecting:
    [42]
ok
Trying:
    def f():
        return 1//0
Expecting nothing
ok
Trying:
    def g():
        yield f()  # the zero division exception propagates
        yield 42   # and we'll never get here
Expecting nothing
ok
Trying:
    k = g()
Expecting nothing
ok
Trying:
    k.next()
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "<stdin>", line 2, in g
      File "<stdin>", line 2, in f
    ZeroDivisionError: integer division by zero
ok
Trying:
    k.next()  # and the generator cannot be resumed
Expecting:
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    StopIteration
ok
Trying:
    def f():
        try:
            yield 1
            try:
                yield 2
                1//0
                yield 3  # never get here
            except ZeroDivisionError:
                yield 4
                yield 5
                raise
            except:
                yield 6
            yield 7     # the "raise" above stops this
        except:
            yield 8
        yield 9
        try:
            x = 12
        finally:
            yield 10
        yield 11
Expecting nothing
ok
Trying:
    print list(f())
Expecting:
    [1, 2, 4, 5, 8, 9, 10, 11]
ok
Trying:
    class Tree:

        def __init__(self, label, left=None, right=None):
            self.label = label
            self.left = left
            self.right = right

        def __repr__(self, level=0, indent="    "):
            s = level*indent + repr(self.label)
            if self.left:
                s = s + "\n" + self.left.__repr__(level+1, indent)
            if self.right:
                s = s + "\n" + self.right.__repr__(level+1, indent)
            return s

        def __iter__(self):
            return inorder(self)
Expecting nothing
ok
Trying:
    def tree(list):
        n = len(list)
        if n == 0:
            return []
        i = n // 2
        return Tree(list[i], tree(list[:i]), tree(list[i+1:]))
Expecting nothing
ok
Trying:
    t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Expecting nothing
ok
Trying:
    def inorder(t):
        if t:
            for x in inorder(t.left):
                yield x
            yield t.label
            for x in inorder(t.right):
                yield x
Expecting nothing
ok
Trying:
    t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Expecting nothing
ok
Trying:
    for x in t:
        print x,
Expecting:
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
ok
Trying:
    def inorder(node):
        stack = []
        while node:
            while node.left:
                stack.append(node)
                node = node.left
            yield node.label
            while not node.right:
                try:
                    node = stack.pop()
                except IndexError:
                    return
                yield node.label
            node = node.right
Expecting nothing
ok
Trying:
    for x in t:
        print x,
Expecting:
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
ok
Trying:
    def f():
        return 22
        yield 1
Expecting:
    Traceback (most recent call last):
      ..
    SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[0]>, line 2)
ok
Trying:
    def f():
        yield 1
        return 22
Expecting:
    Traceback (most recent call last):
      ..
    SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[1]>, line 3)
ok
Trying:
    def f():
        yield 1
        return None
Expecting:
    Traceback (most recent call last):
      ..
    SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[2]>, line 3)
ok
Trying:
    def f():
        yield 1
        return
Expecting nothing
ok
Trying:
    def f():
        try:
            yield 1
        finally:
            pass
Expecting:
    Traceback (most recent call last):
      ..
    SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[4]>, line 3)
ok
Trying:
    def f():
        try:
            try:
                1//0
            except ZeroDivisionError:
                yield 666  # bad because *outer* try has finally
            except:
                pass
        finally:
            pass
Expecting:
    Traceback (most recent call last):
      ...
    SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[5]>, line 6)
ok
Trying:
    def f():
        try:
            try:
                yield 12
                1//0
            except ZeroDivisionError:
                yield 666
            except:
                try:
                    x = 12
                finally:
                    yield 12
        except:
            return
Expecting nothing
ok
Trying:
    list(f())
Expecting:
    [12, 666]
ok
Trying:
    def f():
       yield
Expecting:
    Traceback (most recent call last):
    SyntaxError: invalid syntax
ok
Trying:
    def f():
       if 0:
           yield
Expecting:
    Traceback (most recent call last):
    SyntaxError: invalid syntax
ok
Trying:
    def f():
        if 0:
            yield 1
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'generator'>
ok
Trying:
    def f():
       if "":
           yield None
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'generator'>
ok
Trying:
    def f():
        return
        try:
            if x==4:
                pass
            elif 0:
                try:
                    1//0
                except SyntaxError:
                    pass
                else:
                    if 0:
                        while 12:
                            x += 1
                            yield 2 # don't blink
                            f(a, b, c, d, e)
            else:
                pass
        except:
            x = 1
        return
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'generator'>
ok
Trying:
    def f():
        if 0:
            def g():
                yield 1
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'NoneType'>
ok
Trying:
    def f():
        if 0:
            class C:
                def __init__(self):
                    yield 1
                def f(self):
                    yield 2
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'NoneType'>
ok
Trying:
    def f():
        if 0:
            return
        if 0:
            yield 2
Expecting nothing
ok
Trying:
    type(f())
Expecting:
    <type 'generator'>
ok
Trying:
    def f():
        if 0:
            lambda x:  x        # shouldn't trigger here
            return              # or here
            def f(i):
                return 2*i      # or here
            if 0:
                return 3        # but *this* sucks (line 8)
        if 0:
            yield 2             # because it's a generator
Expecting:
    Traceback (most recent call last):
    SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[22]>, line 8)
ok
Trying:
    def f():
        for i in range(3):
            try:
                continue
            finally:
                yield i
Expecting nothing
ok
Trying:
    g = f()
Expecting nothing
ok
Trying:
    print g.next()
Expecting:
    0
ok
Trying:
    print g.next()
Expecting:
    1
ok
Trying:
    print g.next()
Expecting:
    2
ok
Trying:
    print g.next()
Expecting:
    Traceback (most recent call last):
    StopIteration
ok
Trying:
    import weakref
Expecting nothing
ok
Trying:
    def gen():
        yield 'foo!'
Expecting nothing
ok
Trying:
    wr = weakref.ref(gen)
Expecting nothing
ok
Trying:
    wr() is gen
Expecting:
    True
ok
Trying:
    p = weakref.proxy(gen)
Expecting nothing
ok
Trying:
    gi = gen()
Expecting nothing
ok
Trying:
    wr = weakref.ref(gi)
Expecting nothing
ok
Trying:
    wr() is gi
Expecting:
    True
ok
Trying:
    p = weakref.proxy(gi)
Expecting nothing
ok
Trying:
    list(p)
Expecting:
    ['foo!']
ok
Trying:
    def firstn(g, n):
        return [g.next() for i in range(n)]
Expecting nothing
ok
Trying:
    def intsfrom(i):
        while 1:
            yield i
            i += 1
Expecting nothing
ok
Trying:
    firstn(intsfrom(5), 7)
Expecting:
    [5, 6, 7, 8, 9, 10, 11]
ok
Trying:
    def exclude_multiples(n, ints):
        for i in ints:
            if i % n:
                yield i
Expecting nothing
ok
Trying:
    firstn(exclude_multiples(3, intsfrom(1)), 6)
Expecting:
    [1, 2, 4, 5, 7, 8]
ok
Trying:
    def sieve(ints):
        prime = ints.next()
        yield prime
        not_divisible_by_prime = exclude_multiples(prime, ints)
        for p in sieve(not_divisible_by_prime):
            yield p
Expecting nothing
ok
Trying:
    primes = sieve(intsfrom(2))
Expecting nothing
ok
Trying:
    firstn(primes, 20)
Expecting:
    [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
ok
Trying:
    def times(n, g):
        for i in g:
            yield n * i
Expecting nothing
ok
Trying:
    firstn(times(10, intsfrom(1)), 10)
Expecting:
    [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
ok
Trying:
    def merge(g, h):
        ng = g.next()
        nh = h.next()
        while 1:
            if ng < nh:
                yield ng
                ng = g.next()
            elif ng > nh:
                yield nh
                nh = h.next()
            else:
                yield ng
                ng = g.next()
                nh = h.next()
Expecting nothing
ok
Trying:
    def m235():
        yield 1
        me_times2 = times(2, m235())
        me_times3 = times(3, m235())
        me_times5 = times(5, m235())
        for i in merge(merge(me_times2,
                             me_times3),
                       me_times5):
            yield i
Expecting nothing
ok
Trying:
    result = m235()
Expecting nothing
ok
Trying:
    for i in range(3):
        print firstn(result, 15)
Expecting:
    [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
    [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
    [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
ok
Trying:
    class LazyList:
        def __init__(self, g):
            self.sofar = []
            self.fetch = g.next

        def __getitem__(self, i):
            sofar, fetch = self.sofar, self.fetch
            while i >= len(sofar):
                sofar.append(fetch())
            return sofar[i]
Expecting nothing
ok
Trying:
    def m235():
        yield 1
        # Gack:  m235 below actually refers to a LazyList.
        me_times2 = times(2, m235)
        me_times3 = times(3, m235)
        me_times5 = times(5, m235)
        for i in merge(merge(me_times2,
                             me_times3),
                       me_times5):
            yield i
Expecting nothing
ok
Trying:
    m235 = LazyList(m235())
Expecting nothing
ok
Trying:
    for i in range(5):
        print [m235[j] for j in range(15*i, 15*(i+1))]
Expecting:
    [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
    [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
    [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
    [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384]
    [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675]
ok
Trying:
    def fibgen(a, b):

        def sum(g, h):
            while 1:
                yield g.next() + h.next()

        def tail(g):
            g.next()    # throw first away
            for x in g:
                yield x

        yield a
        yield b
        for s in sum(iter(fib),
                     tail(iter(fib))):
            yield s
Expecting nothing
ok
Trying:
    fib = LazyList(fibgen(1, 2))
Expecting nothing
ok
Trying:
    firstn(iter(fib), 17)
Expecting:
    [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]
ok
Trying:
    def g():
        for i in range(3):
            yield None
        yield None
        return
Expecting nothing
ok
Trying:
    list(g())
Expecting:
    [None, None, None, None]
ok
Trying:
    def g():
        yield 1
        try:
            raise StopIteration
        except:
            yield 2
        yield 3
Expecting nothing
ok
Trying:
    list(g())
Expecting:
    [1, 2, 3]
ok
Trying:
    def gcomb(x, k):
        "Generate all combinations of k elements from list x."

        if k > len(x):
            return
        if k == 0:
            yield []
        else:
            first, rest = x[0], x[1:]
            # A combination does or doesn't contain first.
            # If it does, the remainder is a k-1 comb of rest.
            for c in gcomb(rest, k-1):
                c.insert(0, first)
                yield c
            # If it doesn't contain first, it's a k comb of rest.
            for c in gcomb(rest, k):
                yield c
Expecting nothing
ok
Trying:
    seq = range(1, 5)
Expecting nothing
ok
Trying:
    for k in range(len(seq) + 2):
        print "%d-combs of %s:" % (k, seq)
        for c in gcomb(seq, k):
            print "   ", c
Expecting:
    0-combs of [1, 2, 3, 4]:
        []
    1-combs of [1, 2, 3, 4]:
        [1]
        [2]
        [3]
        [4]
    2-combs of [1, 2, 3, 4]:
        [1, 2]
        [1, 3]
        [1, 4]
        [2, 3]
        [2, 4]
        [3, 4]
    3-combs of [1, 2, 3, 4]:
        [1, 2, 3]
        [1, 2, 4]
        [1, 3, 4]
        [2, 3, 4]
    4-combs of [1, 2, 3, 4]:
        [1, 2, 3, 4]
    5-combs of [1, 2, 3, 4]:
ok
Trying:
    def g():
        yield 1
Expecting nothing
ok
Trying:
    type(g)
Expecting:
    <type 'function'>
ok
Trying:
    i = g()
Expecting nothing
ok
Trying:
    type(i)
Expecting:
    <type 'generator'>
ok
Trying:
    [s for s in dir(i) if not s.startswith('_')]
Expecting:
    ['gi_frame', 'gi_running', 'next']
ok
Trying:
    print i.next.__doc__
Expecting:
    x.next() -> the next value, or raise StopIteration
ok
Trying:
    iter(i) is i
Expecting:
    True
ok
Trying:
    import types
Expecting nothing
ok
Trying:
    isinstance(i, types.GeneratorType)
Expecting:
    True
ok
Trying:
    i.gi_running
Expecting:
    0
ok
Trying:
    type(i.gi_frame)
Expecting:
    <type 'frame'>
ok
Trying:
    i.gi_running = 42
Expecting:
    Traceback (most recent call last):
      ...
    TypeError: readonly attribute
ok
Trying:
    def g():
        yield me.gi_running
Expecting nothing
ok
Trying:
    me = g()
Expecting nothing
ok
Trying:
    me.gi_running
Expecting:
    0
ok
Trying:
    me.next()
Expecting:
    1
ok
Trying:
    me.gi_running
Expecting:
    0
ok
Trying:
    class disjointSet:
        def __init__(self, name):
            self.name = name
            self.parent = None
            self.generator = self.generate()

        def generate(self):
            while not self.parent:
                yield self
            for x in self.parent.generator:
                yield x

        def find(self):
            return self.generator.next()

        def union(self, parent):
            if self.parent:
                raise ValueError("Sorry, I'm not a root!")
            self.parent = parent

        def __str__(self):
            return self.name
Expecting nothing
ok
Trying:
    names = "ABCDEFGHIJKLM"
Expecting nothing
ok
Trying:
    sets = [disjointSet(name) for name in names]
Expecting nothing
ok
Trying:
    roots = sets[:]
Expecting nothing
ok
Trying:
    import random
Expecting nothing
ok
Trying:
    gen = random.WichmannHill(42)
Expecting nothing
ok
Trying:
    while 1:
        for s in sets:
            print "%s->%s" % (s, s.find()),
        print
        if len(roots) > 1:
            s1 = gen.choice(roots)
            roots.remove(s1)
            s2 = gen.choice(roots)
            s1.union(s2)
            print "merged", s1, "into", s2
        else:
            break
Expecting:
    A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
    merged D into G
    A->A B->B C->C D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
    merged C into F
    A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
    merged L into A
    A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->A M->M
    merged H into E
    A->A B->B C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
    merged B into E
    A->A B->E C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
    merged J into G
    A->A B->E C->F D->G E->E F->F G->G H->E I->I J->G K->K L->A M->M
    merged E into G
    A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->M
    merged M into G
    A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->G
    merged I into K
    A->A B->G C->F D->G E->G F->F G->G H->G I->K J->G K->K L->A M->G
    merged K into A
    A->A B->G C->F D->G E->G F->F G->G H->G I->A J->G K->A L->A M->G
    merged F into A
    A->A B->G C->A D->G E->G F->A G->G H->G I->A J->G K->A L->A M->G
    merged A into G
    A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
ok
15 items had no tests:
    test.test_generators
    test.test_generators.Knights
    test.test_generators.Knights.__init__
    test.test_generators.Knights._init_board
    test.test_generators.Knights.coords2index
    test.test_generators.Knights.index2coords
    test.test_generators.Knights.printsolution
    test.test_generators.Knights.solve
    test.test_generators.Queens
    test.test_generators.Queens.__init__
    test.test_generators.Queens.printsolution
    test.test_generators.Queens.solve
    test.test_generators.conjoin
    test.test_generators.flat_conjoin
    test.test_generators.test_main
7 items passed all tests:
  12 tests in test.test_generators.__test__.conjoin
  31 tests in test.test_generators.__test__.email
  21 tests in test.test_generators.__test__.fun
  22 tests in test.test_generators.__test__.pep
  29 tests in test.test_generators.__test__.syntax
  29 tests in test.test_generators.__test__.tut
  10 tests in test.test_generators.__test__.weakref
154 tests in 22 items.
154 passed and 0 failed.
Test passed.
doctest (test.test_generators) ... 154 tests with zero failures

stderr

Loading grammar /home/hpk/pypy-dist/pypy/interpreter/pyparser/data/Grammar2.5a
faking <type 'module'>
faking <type 'file'>
faking <type 'posix.stat_result'>
faking <type 'posix.statvfs_result'>
fake-wrapping interp file <open file '<stdout>', mode 'w' at 0x558e6068>
fake-wrapping interp file <open file '<stderr>', mode 'w' at 0x558e60b0>
fake-wrapping interp file <open file '<stdin>', mode 'r' at 0x558e6020>