コード例 #1
0
ファイル: test_utils.py プロジェクト: Python-PyBD/logbook
def test_logged_if_slow_deprecated(logger, test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD,
                            func=logbook.error):
            sleep(2 * _THRESHOLD)

    assert test_handler.records[0].level == logbook.ERROR
    assert test_handler.records[0].message == 'checking...'

    with pytest.raises(TypeError):
        logged_if_slow('checking...', logger=logger, func=logger.error)
コード例 #2
0
ファイル: test_utils.py プロジェクト: zuoxiaolei/logbook
def test_logged_if_slow_deprecated(logger, test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...',
                            threshold=_THRESHOLD,
                            func=logbook.error):
            sleep(2 * _THRESHOLD)

    assert test_handler.records[0].level == logbook.ERROR
    assert test_handler.records[0].message == 'checking...'

    with pytest.raises(TypeError):
        logged_if_slow('checking...', logger=logger, func=logger.error)
コード例 #3
0
ファイル: test_utils.py プロジェクト: zuoxiaolei/logbook
def test_logged_if_slow_logger():
    logger = Mock()

    with logged_if_slow('checking...', threshold=_THRESHOLD, logger=logger):
        sleep(2 * _THRESHOLD)

    assert logger.log.call_args == call(logbook.DEBUG, 'checking...')
コード例 #4
0
ファイル: test_utils.py プロジェクト: zuoxiaolei/logbook
def test_logged_if_slow_reached(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD):
            sleep(2 * _THRESHOLD)
        assert len(test_handler.records) == 1
        [record] = test_handler.records
        assert record.message == 'checking...'
コード例 #5
0
ファイル: test_utils.py プロジェクト: Python-PyBD/logbook
def test_logged_if_slow_level(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD,
                            level=logbook.WARNING):
            sleep(2 * _THRESHOLD)

    assert test_handler.records[0].level == logbook.WARNING
コード例 #6
0
ファイル: test_utils.py プロジェクト: Python-PyBD/logbook
def test_logged_if_slow_logger():
    logger = Mock()

    with logged_if_slow('checking...', threshold=_THRESHOLD, logger=logger):
        sleep(2 * _THRESHOLD)

    assert logger.log.call_args == call(logbook.DEBUG, 'checking...')
コード例 #7
0
ファイル: test_utils.py プロジェクト: Python-PyBD/logbook
def test_logged_if_slow_reached(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD):
            sleep(2 * _THRESHOLD)
        assert len(test_handler.records) == 1
        [record] = test_handler.records
        assert record.message == 'checking...'
コード例 #8
0
ファイル: test_utils.py プロジェクト: zuoxiaolei/logbook
def test_logged_if_slow_level(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...',
                            threshold=_THRESHOLD,
                            level=logbook.WARNING):
            sleep(2 * _THRESHOLD)

    assert test_handler.records[0].level == logbook.WARNING
コード例 #9
0
ファイル: test_utils.py プロジェクト: zuoxiaolei/logbook
def test_logged_if_slow_did_not_reached(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD):
            sleep(_THRESHOLD / 2)
        assert len(test_handler.records) == 0
コード例 #10
0
ファイル: test_utils.py プロジェクト: Python-PyBD/logbook
def test_logged_if_slow_did_not_reached(test_handler):
    with test_handler.applicationbound():
        with logged_if_slow('checking...', threshold=_THRESHOLD):
            sleep(_THRESHOLD / 2)
        assert len(test_handler.records) == 0