开发者

how to print stuff within tests on Plone

开发者 https://www.devze.com 2023-03-27 17:42 出处:网络
I\'m writing some integration test with plone.app.testing. Sometimes I want to print something to the console, but it seems to me that stuff get开发者_开发知识库s printed on the console only when a p

I'm writing some integration test with plone.app.testing.

Sometimes I want to print something to the console, but it seems to me that stuff get开发者_开发知识库s printed on the console only when a particular test has finished.

Does plone.app.testing or some of the packages behind have some logging facility which I can use?


To support testing logging output, IOW tests that check that your code is logging things as it should, I think zope.testing intercepts all logging. Additionally, depending on how you're testing, stdout may be replaced or intercepted, as with doctests for example, so printing to stdout may not work either.

Personally, I used pdb.set_trace() or I force a failure temporarily, IOW without committing it, at the point I want to inspect and run the tests with "-D" for pdb.post_mortem() debugging.

You may, however, be able to make some use of zope.testing.loggingsupport to collect the information you want and then you can use a pdb.set_trace() or "-D" to get a pdb prompt at which you can inspect whatever handler you created to capture logging output.


Take a look on this also: Redirecting log output to sys.stdout on tests.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号