Nosetests logcapture与Pylons无法正常工作

时间:2011-04-13 21:59:34

标签: python pylons nosetests

我正在为我正在开发的Pylons Web应用程序编写单元测试。我希望在运行测试时看到logs.debug | info | etc并发生错误,但是现在它只捕获了print()语句。

要进行测试,我会执行以下操作:

nosetests --with-pylons=test.ini --debug-log=test.log --verbosity=3

结果是它不会在日志文件或控制台中输出任何内容。

test.ini正在使用development.ini,它包含以下记录器代码:

[loggers]
keys = root, routes, myapp, sqlalchemy

[handlers]
keys = console, file

[formatters]
keys = generic

[logger_root]
level = DEBUG
handlers = console, file

[logger_routes]
level = INFO
handlers = 
qualname = routes.middleware

[logger_myapp]
level = DEBUG
handlers = 
qualname = myapp

[logger_sqlalchemy]
level = INFO
handlers = 
qualname = sqlalchemy.engine

[handler_console]
class = StreamHandler
args = (sys.stdout, )
level = DEBUG
formatter = generic

[handler_file]
class = FileHandler
args = ('application.log', 'a')
level = DEBUG
formatter = generic

[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s
datefmt = %H:%M:%S

当我启动整个应用程序时,日志记录工作正常。

0 个答案:

没有答案