示例#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 create_state(players, button):
     table = Table()
     deck = Deck()
     deck.shuffle()
     for (sit, player) in players:
         table.sit_in(player, sit)
     if button is None:
         table.rotate_button()
     else:
         table.button = button
     return HandState(table, deck)
示例#3
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(state.dump(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.load(file(initial))
        croupier = Croupier(state, StringIO())
        croupier.conduct()
        success = diff(state, expected)
        if not success:
            print 'F'
            exit(1)
        print '.'