Make nose test runner show logging even if tests pass

 ̄綄美尐妖づ 提交于 2019-12-03 09:35:32

nosetests --help does not make this obvious AT ALL, but the answer is the --debug flag. This flag takes as an argument the name of the logger that you'd like to receive messages from.

Here's a slightly modified version of the OP's code:

# test.py
import unittest
import logging

class Test(unittest.TestCase):
    def test_pass(self):
        logging.getLogger('hide.this').info('HIDE THIS')
        logging.getLogger('show.this').info('TEST PASS')
        self.assertEqual(True, True)

    def test_fail(self):
        logging.getLogger('hide.this').info('HIDE THIS')
        logging.getLogger('show.this').info('TEST FAIL')
        self.assertEqual(True, False)

For this example, nosetests test.py --debug=show.this should do the trick.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!