예제 #1
0
def test_dojo_dojo_timer_running(input, mocked_dojo):
    mocked_dojo.is_running = True
    mocked_dojo.timer.is_running = True

    def stop_dojo():
        mocked_dojo.is_running = False

    def stop_timer():
        mocked_dojo.timer.is_running = False

    mocked_dojo.round_info = mock.Mock(side_effect=stop_timer)
    mocked_dojo.round_finished = mock.Mock(side_effect=stop_dojo)
    mocked_dojo.dojo()
예제 #2
0
def test_code_handler_on_modified(get_interval, mocked_code_handler):
    mocked_code_handler.test_runner.run.return_value = True
    get_interval.return_value = 10

    mocked_code_handler.on_modified(mock.Mock())

    assert get_interval.called
    assert mocked_code_handler.test_runner.run.called
예제 #3
0
파일: dojo.py 프로젝트: zsinx6/dojo-toolkit
    def __init__(self,
                 code_path,
                 round_time=None,
                 mute=False,
                 test_runner=None):
        self.code_path = code_path
        self.round_time = round_time or self.ROUND_TIME
        self.sound_player = mock.Mock() if mute else SoundHandler()

        test_runner = test_runner or DoctestTestRunner(
            code_path=code_path, sound_player=self.sound_player)
        event_handler = DojoCodeHandler(dojo=self, test_runner=test_runner)

        self.observer = Observer()
        self.observer.schedule(event_handler, self.code_path, recursive=False)

        self.timer = Timer(self.round_time)
예제 #4
0
def mocked_dojo():
    with mock.patch('dojo_toolkit.dojo.Observer'), \
            mock.patch('dojo_toolkit.dojo.Timer'), \
            mock.patch('dojo_toolkit.dojo.SoundHandler'):
        return Dojo('/foo/bar', test_runner=mock.Mock())
예제 #5
0
def test_dojo_dojo(input, mocked_dojo):
    mocked_dojo.is_running = True
    mocked_dojo.timer.is_running = False
    mocked_dojo.round_finished = mock.Mock(side_effect=KeyboardInterrupt)
    with pytest.raises(KeyboardInterrupt):
        mocked_dojo.dojo()
예제 #6
0
def wrong_test_runner(code_path):
    with mock.patch('dojo_toolkit.test_runner.notifier'):
        return WrongTestRunner(code_path, sound_player=mock.Mock())
예제 #7
0
def mock_test_runner(code_path):
    return MockTestRunner(code_path, sound_player=mock.Mock())
예제 #8
0
def test_code_handler():
    code_handler = DojoCodeHandler(test_runner=mock.Mock(), dojo=mock.Mock())
    assert code_handler.last_test_run_time
예제 #9
0
def mocked_code_handler():
    code_handler = DojoCodeHandler(test_runner=mock.Mock(), dojo=mock.Mock())
    return code_handler