@@ -24,11 +24,10 @@ Shows failed tests like so::
2424 ==================== 2 failed in 0.02 seconds =====================
2525
2626By default each captured log message shows the module, line number, log level
27- and message. Showing the exact module and line number is useful for testing and
28- debugging. If desired the log format and date format can be specified to
29- anything that the logging module supports.
27+ and message.
3028
31- Running pytest specifying formatting options::
29+ If desired the log and date format can be specified to
30+ anything that the logging module supports by passing specific formatting options::
3231
3332 pytest --log-format="%(asctime)s %(levelname)s %(message)s" \
3433 --log-date-format="%Y-%m-%d %H:%M:%S"
@@ -43,7 +42,7 @@ Shows failed tests like so::
4342 text going to stderr
4443 ==================== 2 failed in 0.02 seconds =====================
4544
46- These options can also be customized through a configuration file:
45+ These options can also be customized through `` pytest.ini `` file:
4746
4847.. code-block :: ini
4948
5655
5756 pytest --no-print-logs
5857
59- Or in you ``pytest.ini ``:
58+ Or in the ``pytest.ini `` file :
6059
6160.. code-block :: ini
6261
@@ -72,6 +71,10 @@ Shows failed tests in the normal manner as no logs were captured::
7271 text going to stderr
7372 ==================== 2 failed in 0.02 seconds =====================
7473
74+
75+ caplog fixture
76+ ^^^^^^^^^^^^^^
77+
7578Inside tests it is possible to change the log level for the captured log
7679messages. This is supported by the ``caplog `` fixture::
7780
@@ -136,25 +139,21 @@ You can call ``caplog.clear()`` to reset the captured log records in a test::
136139 assert ['Foo'] == [rec.message for rec in caplog.records]
137140
138141
139- Accessing logs from other test stages
140- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142+ The ``caplop.records `` attribute contains records from the current stage only, so
143+ inside the ``setup `` phase it contains only setup logs, same with the ``call `` and
144+ ``teardown `` phases.
141145
142- The ``caplop.records `` fixture contains records from the current stage only. So
143- inside the setup phase it contains only setup logs, same with the call and
144- teardown phases. To access logs from other stages you can use
145- ``caplog.get_handler('setup').records ``. Valid stages are ``setup ``, ``call ``
146- and ``teardown ``.
147-
148-
149- .. _live_logs :
146+ It is possible to access logs from other stages with ``caplog.get_handler('setup').records ``.
150147
151148
152149caplog fixture API
153- ^^^^^^^^^^^^^^^^^^
150+ ~~~~~~~~~~~~~~~~~~
154151
155152.. autoclass :: _pytest.logging.LogCaptureFixture
156153 :members:
157154
155+ .. _live_logs :
156+
158157Live Logs
159158^^^^^^^^^
160159
0 commit comments