def test_board_given_first_person_picks_correct_board_was_successful(self): fake_passenger_assignments = [2, 1, 3, 5, 4] size_of_plane = 5 mock_random = MagicMock() mock_random.random_number = MagicMock(return_value=1) subject = Plane(fake_passenger_assignments, size_of_plane, mock_random) subject.board() result = subject.successful_board assert result is True
def run(): number_of_succesful_boards = 0 plane_tickets = Plane.create_list_of_all_seats(100) for i in range(0, 1000): plane = Plane(plane_tickets, 100) plane.board() if plane.successful_board: number_of_succesful_boards += 1 probability = (number_of_succesful_boards / 1000) * 100 print( "\nThe probability over the course of 1000 boardings of the last passenger getting their correct seat is {:0.2f}%.\n" .format(probability))