示例#1
0
 def do_play_hand(self):
     source = sys.stdin
     dest = sys.stdout
     state = HandState.load(source)
     croupier = Croupier(state, sys.stderr)
     croupier.conduct()
     dest.write(state.dump(False))
示例#2
0
 def do_play_hand(self):
     source = sys.stdin
     dest = sys.stdout
     state = handstate_repr.parse(source)
     croupier = Croupier(state, sys.stderr)
     croupier.conduct()
     dump = handstate_repr.dump(state, False)
     print >> dest, dump,
示例#3
0
 def do_play_hand(self):
     source = sys.stdin
     dest = sys.stdout
     state = handstate_repr.parse(source)
     croupier = Croupier(state, sys.stderr)
     croupier.conduct()
     dump = handstate_repr.dump(state, False)
     print >> dest, dump,
示例#4
0
    current_path = os.path.abspath(os.path.dirname(__file__))
    fixtures_pattern = current_path + '/fixture/*.in.xml'
    for initial in iglob(fixtures_pattern):
        if os.path.basename(initial).startswith('_'):
            continue
        expected = re.sub(r'(\..*){2}$', '.out.xml', initial)
        yield initial, expected


def diff(state, expected):
    tmp = file(tempfile.mkstemp()[1], 'w')
    tmp.write(handstate_repr.dump(state, False))
    tmp.close()
    code = os.system('diff -b %s %s' % (expected, tmp.name))
    return not code


if __name__ == '__main__':

    for initial, expected in fixtures():
        success = False
        print '%-40s' % os.path.basename(initial),
        state = handstate_repr.parse(file(initial))
        croupier = Croupier(state, StringIO())
        croupier.conduct()
        success = diff(state, expected)
        if not success:
            print 'F'
            exit(1)
        print '.'