Skip to content

Instantly share code, notes, and snippets.

@nazarewk
Created October 3, 2019 10:12
Show Gist options
  • Save nazarewk/5c10b1c1842ee8561ace45976d1211c6 to your computer and use it in GitHub Desktop.
Save nazarewk/5c10b1c1842ee8561ace45976d1211c6 to your computer and use it in GitHub Desktop.
pytest + live-logs doctests
e-kfni@nazarewk-portable ~/dev/nazarewk/pytest-live-logs-error % pytest
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.4, pytest-5.2.0, py-1.8.0, pluggy-0.13.0
rootdir: /home/e-kfni/dev/nazarewk/pytest-live-logs-error, inifile: pytest.ini
collected 1 item
example.py::example.do
-------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
INFO example:example.py:11 qwe
FAILED [100%]
==================================================================================================== FAILURES =====================================================================================================
______________________________________________________________________________________________ [doctest] example.do _______________________________________________________________________________________________
007
008 >>> do()
Expected:
True
Got nothing
/home/e-kfni/dev/nazarewk/pytest-live-logs-error/example.py:8: DocTestFailure
---------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------
True
------------------------------------------------------------------------------------------------ Captured log call ------------------------------------------------------------------------------------------------
INFO example:example.py:11 qwe
================================================================================================ 1 failed in 0.03s ================================================================================================
import logging
log = logging.getLogger(__name__)
def do():
"""
>>> do()
True
"""
log.info('qwe')
return True
[pytest]
norecursedirs = .* *.egg-info
addopts =
--doctest-modules
log_cli = true
log_cli_level = info
python3.7 -m venv .venv
. .venv/bin/activate
pip install pytest==5.2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment