Closed
Description
Description
Using Pytest 3.2 and --junit-xml the output XML file gets polluted by logging messages.
Pip list
pytest==3.2.0
coverage==4.4.1
pytest-cov==2.5.1
pytest-reqs==0.0.6
mock==2.0.0
Versions
pytest==3.2.0 and nixos.
Example
This following example is enough to reproduce the issue.
If I run pytest tests.py
the logging messages don't show (correctly).
Running instead pytest tests.py --junit-xml output.xml
the log messages get into the XML file making it unusable.
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
logger = logging.getLogger(__name__)
def function():
logger.info("Hello from inside a test")
return 2
def test_sample():
assert function() == 2
if __name__ == '__main__':
function()