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')
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__()
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
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__()