コード例 #1
0
 def test_play_game(self, mock_method):
     button_shooter = ButtonShooterWindow("username")
     button_shooter.initialize_game = mock.MagicMock()
     button_shooter.show = mock.MagicMock()
     button_shooter.required_targets = 100
     button_shooter.show_start_screen = mock.MagicMock(
         return_value=QMessageBox.AcceptRole)
     button_shooter.timer = mock.MagicMock()
     button_shooter.timer.start = mock.MagicMock()
     button_shooter.show_buttons = mock.MagicMock()
     button_shooter.play_game(1)
     button_shooter.show_buttons.assert_called()
コード例 #2
0
    def test_update_timer(self, mock_method):
        button_shooter = ButtonShooterWindow("username")
        button_shooter.countdown = 5
        button_shooter.countdown_label = mock.MagicMock()
        button_shooter.countdown_label.setText = mock.MagicMock()
        button_shooter.timer = mock.MagicMock()
        button_shooter.timer.stop = mock.MagicMock()
        button_shooter.end_the_game = mock.MagicMock()

        for i in range(5):
            button_shooter.update_timer()

        button_shooter.timer.stop.assert_called()
        button_shooter.end_the_game.assert_called()