示例#1
0
def test_logger_norecord():
    logger_obj = Logger(None, 'nengo.utils.tests.test_testing',
                        'test_logger_norecord')
    with logger_obj as logger:
        logger.info("Testing that logger doesn't record")
    with pytest.raises(ValueError):
        logger_obj.get_filepath(ext='txt')
示例#2
0
def test_logger_norecord():
    logger_obj = Logger(None,
                        'nengo.utils.tests.test_testing',
                        'test_logger_norecord')
    with logger_obj as logger:
        logger.info("Testing that logger doesn't record")
    with pytest.raises(ValueError):
        logger_obj.get_filepath(ext='txt')
示例#3
0
文件: conftest.py 项目: CamZHU/nengo
def logger(request):
    """a logging.Logger object.

    Please use this if your test emits log messages.

    This will keep saved logs organized in a simulator-specific folder,
    with an automatically generated name.
    """
    dirname = recorder_dirname(request, "logs")
    logger = Logger(dirname, request.module.__name__, parametrize_function_name(request, request.function.__name__))
    request.addfinalizer(lambda: logger.__exit__(None, None, None))
    return logger.__enter__()
示例#4
0
def test_logger_record():
    logger_obj = Logger('nengo.simulator.logs',
                        'nengo.utils.tests.test_testing', 'test_logger_record')
    with logger_obj as logger:
        logger.info("Testing that logger records")
    path = logger_obj.get_filepath(ext='txt')
    assert os.path.exists(path)
    os.remove(path)
    # This will remove the logger directory, only if it's empty
    try:
        os.rmdir(logger_obj.dirname)
    except OSError as ex:
        assert ex.errno == errno.ENOTEMPTY
示例#5
0
def logger(request):
    """A logging.Logger object.

    Please use this if your test emits log messages.

    This will keep saved logs organized in a simulator-specific folder,
    with an automatically generated name.
    """
    dirname = recorder_dirname(request, 'logs')
    logger = Logger(
        dirname, request.module.__name__,
        parametrize_function_name(request, request.function.__name__))
    request.addfinalizer(lambda: logger.__exit__(None, None, None))
    return logger.__enter__()
示例#6
0
def test_logger_record():
    logger_obj = Logger('nengo.simulator.logs',
                        'nengo.utils.tests.test_testing',
                        'test_logger_record')
    with logger_obj as logger:
        logger.info("Testing that logger records")
    path = logger_obj.get_filepath(ext='txt')
    assert os.path.exists(path)
    os.remove(path)
    # This will remove the logger directory, only if it's empty
    try:
        os.rmdir(logger_obj.dirname)
    except OSError as ex:
        assert ex.errno == errno.ENOTEMPTY