xmlrunner/unittest-xml-reporting

Unable to print logging output

Nivalam opened this issue · 1 comments

The output is not showing when using xmlrunner with the logging module,

For example, in this code, the logging output is not showing in the xml report.

import unittest
import logging
import xmlrunner
import sys


class Test(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        logging.getLogger().debug("setUpClass")

    def test_step_001(self):
        logging.getLogger().debug("test_step_001")

    @classmethod
    def tearDownClass(cls):
        logging.getLogger().debug("tearDownClass")


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s", stream=sys.stdout)
    unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))

That's right.

    logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s", stream=sys.stdout)
    unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))

in your example you are calling logging.basicConfig outside of a test, so at that point you are dealing with the actual sys.stdout.