mercredi 28 juin 2017

When calling pytest on a directory, doesn't show captured stdout upon test failure

If I use pytest on a singular test file:

pytest -v tests/file_to_test.py

Then my logger will be captured in stdout. However, if I run pytest on the whole directory of tests:

pytest -v tests/file_to_test.py

I do not get the captured stdout.

For the logging, I am using

logging.basicConfig(level=logging.INFO, stream=sys.stdout)
logger = logging.getLogger(__name__)
...
logger.info('show in stdout')

and if I use a plain print statement, the captured stdout is shown.

I have tried pytest-capturelog and pytest-catchlog and neither work for me when I run the whole directory. Any ideas?

EDIT: -s also isn't want I am looking for here.

Aucun commentaire:

Enregistrer un commentaire