Beispiel #1
0
    def test_file(self, mocker):
        mock = mocker.patch('logging.config.fileConfig')

        # anything that is not a boolean is treated like a file
        autosuspend.configure_logging(42)

        mock.assert_called_once_with(42)
    def test_file(self, mocker) -> None:
        mock = mocker.patch("logging.config.fileConfig")

        # anything that is not a boolean is treated like a file
        autosuspend.configure_logging(42, False)  # type: ignore

        mock.assert_called_once_with(42)
Beispiel #3
0
    def test_file_fallback(self, mocker):
        mock = mocker.patch('logging.config.fileConfig',
                            side_effect=RuntimeError())
        mock_basic = mocker.patch('logging.basicConfig')

        # anything that is not a boolean is treated like a file
        autosuspend.configure_logging(42)

        mock.assert_called_once_with(42)
        mock_basic.assert_called_once_with(level=logging.WARNING)
Beispiel #4
0
    def test_standard(self, mocker):
        mock = mocker.patch('logging.basicConfig')

        autosuspend.configure_logging(False)

        mock.assert_called_once_with(level=logging.WARNING)
Beispiel #5
0
    def test_debug(self, mocker):
        mock = mocker.patch('logging.basicConfig')

        autosuspend.configure_logging(True)

        mock.assert_called_once_with(level=logging.DEBUG)