def test_bingo(self): b = Bingo(self.players) for _ in range(1, 76): number = b.draw() assert 0 < number < 76 assert len(b.winners) == len(self.players) with pytest.raises(CageEmptyError): b.draw()
class BingoTest(TestCase): def setUp(self): super().setUp() self.bingo = Bingo() def test_bingo_call_number_should_return_number_between_one_and_seventyfive_inclusive( self): number = self.bingo.call_number() self.assertGreaterEqual(number, LOWER_BOUND) self.assertLessEqual(number, UPPER_BOUND) def test_bingo_call_number_should_return_unique_random_numbers_between_one_and_seventyfive_inclusive( self): numbers = set() for i in range(0, UPPER_BOUND): numbers.add(self.bingo.call_number()) self.assertEqual(UPPER_BOUND, len(numbers)) def test_bingo_check_bingo_card_that_has_checked_all_his_numbers(self): # We are going to allow the player to join after the start (I think this is not allowed in the real life) numbers = self.call_twenty_five_numbers() columns = self.create_column_with(numbers) card = BingoCard(columns) self.assertTrue(self.bingo.check_card(card)) def test_bingo_check_bingo_card_that_has_not_checked_all_his_numbers(self): numbers = [i for i in range(1, 76)] card = BingoCard(self.create_column_with(numbers[1:25])) self.assertFalse(self.bingo.check_card(card)) def call_twenty_five_numbers(self): return [self.bingo.call_number() for _ in range(25)] def create_column_with(self, numbers): return [numbers[x:x + 5] for x in range(5)]
class BingoTest(TestCase): def setUp(self): super().setUp() self.bingo = Bingo() def test_bingo_call_number_should_return_number_between_one_and_seventyfive_inclusive(self): number = self.bingo.call_number() self.assertGreaterEqual(number, LOWER_BOUND) self.assertLessEqual(number, UPPER_BOUND) def test_bingo_call_number_should_return_unique_random_numbers_between_one_and_seventyfive_inclusive(self): numbers = set() for i in range(0, UPPER_BOUND): numbers.add(self.bingo.call_number()) self.assertEqual(UPPER_BOUND, len(numbers)) def test_bingo_check_bingo_card_that_has_checked_all_his_numbers(self): # We are going to allow the player to join after the start (I think this is not allowed in the real life) numbers = self.call_twenty_five_numbers() columns = self.create_column_with(numbers) card = BingoCard(columns) self.assertTrue(self.bingo.check_card(card)) def test_bingo_check_bingo_card_that_has_not_checked_all_his_numbers(self): numbers = [i for i in range(1, 76)] card = BingoCard(self.create_column_with(numbers[1:25])) self.assertFalse(self.bingo.check_card(card)) def call_twenty_five_numbers(self): return [self.bingo.call_number() for _ in range(25)] def create_column_with(self, numbers): return [numbers[x:x + 5] for x in range(5)]
def setUp(self): super().setUp() self.bingo = Bingo()