Пример #1
0
    def test_exception_logging(self):
        executor = Executor()
        executor._log = Mock()

        with patch.object(Runnable, 'run', side_effect=Exception):
            executor.run(Runnable)
        executor.wait()

        self.assertEqual(1, executor._log.error.call_count)
Пример #2
0
    def test_exception_logging(self):
        executor = Executor()
        executor._log = Mock()

        with patch.object(Runnable, 'run', side_effect=Exception):
            executor.run(Runnable)
        executor.wait()

        self.assertEqual(1, executor._log.error.call_count)
Пример #3
0
    def test_calledprocesserror_logging(self):
        executor = Executor()
        executor._log = Mock()
        exception = CalledProcessError(returncode=1, cmd='command')

        with patch.object(Runnable, 'run', side_effect=exception):
            executor.run(Runnable)
        executor.wait()

        self.assertEqual(1, executor._log.error.call_count)
Пример #4
0
    def test_calledprocesserror_logging(self):
        executor = Executor()
        executor._log = Mock()
        exception = CalledProcessError(returncode=1, cmd='command')

        with patch.object(Runnable, 'run', side_effect=exception):
            executor.run(Runnable)
        executor.wait()

        self.assertEqual(1, executor._log.error.call_count)
Пример #5
0
    def test_logged_title_when_it_differs_from_command(self):
        command, title = 'command', 'title'

        runnable = Runnable()
        runnable.title = title
        exception = CalledProcessError(returncode=1, cmd=command)
        runnable.run = Mock(side_effect=exception)

        executor = Executor()
        executor._log = Mock()
        executor.run(runnable)
        executor.wait()

        executor._log.error.assert_called_once_with(Matcher(has_title))
Пример #6
0
    def test_if_logged_title_is_hidden_if_it_equals_command(self):
        command = 'command'

        runnable = Runnable()
        runnable.title = command
        exception = CalledProcessError(returncode=1, cmd=command)
        runnable.run = Mock(side_effect=exception)

        executor = Executor()
        executor._log = Mock()
        executor.run(runnable)
        executor.wait()

        executor._log.error.assert_called_once_with(Matcher(has_not_title))
Пример #7
0
    def test_logged_title_when_it_differs_from_command(self):
        command, title = 'command', 'title'

        runnable = Runnable()
        runnable.title = title
        exception = CalledProcessError(returncode=1, cmd=command)
        runnable.run = Mock(side_effect=exception)

        executor = Executor()
        executor._log = Mock()
        executor.run(runnable)
        executor.wait()

        executor._log.error.assert_called_once_with(Matcher(has_title))
Пример #8
0
    def test_if_logged_title_is_hidden_if_it_equals_command(self):
        command = 'command'

        runnable = Runnable()
        runnable.title = command
        exception = CalledProcessError(returncode=1, cmd=command)
        runnable.run = Mock(side_effect=exception)

        executor = Executor()
        executor._log = Mock()
        executor.run(runnable)
        executor.wait()

        executor._log.error.assert_called_once_with(Matcher(has_not_title))