예제 #1
0
 def test_winning_by_column(self):
     for i in xrange(repetitions):
         c = BingoCard()
         winning_column = choice(c.card)
         for num in winning_column:
             c.cross_out(num)
         # when every number on a column is crossed out
         # the card is a winner
         self.assertTrue(c.has_won())
예제 #2
0
 def test_crossing_out(self):
     for i in xrange(repetitions):
         c = BingoCard()
         extraction = randrange(1,76)
         c.cross_out(extraction)
         for column in c.card:
             # when a number is crossed out
             # is not on the card anymore
             self.assertNotIn(extraction, column)
예제 #3
0
 def test_winning_by_row(self):
     for i in xrange(repetitions):
         c = BingoCard()
         random_row = randrange(5)
         winning_row = [column[random_row] for column in c.card]
         for num in winning_row:
             c.cross_out(num)
         # when every number on a row is crossed out
         # the card is a winner
         self.assertTrue(c.has_won())
예제 #4
0
    def test_start_end_game(self):
        for i in xrange(repetitions):
            c = BingoCard()
            # a new card can't be a winner
            self.assertFalse(c.has_won())

            for extraction in xrange(76):
                c.cross_out(extraction)
            # after the extraction of every number
            # a card must be a winner
            self.assertTrue(c.has_won())
예제 #5
0
 def test_winning_by_diagonals(self):
     for i in xrange(repetitions):
         c = BingoCard()
         backwards = choice([True, False])
         if backwards:
             winning_diagonal = [c.card[4-n][n] for n in xrange(5)]
         else:
             winning_diagonal = [c.card[n][n] for n in xrange(5)]
         for num in winning_diagonal:
             c.cross_out(num)
         # when every number on a diagonal is crossed out
         # the card is a winner
         self.assertTrue(c.has_won())