@@ -43,6 +43,8 @@ For example:
4343 1 failed in 0.01 seconds
4444
4545
46+ **Disabling Loggin Capture **
47+
4648Qt logging capture can be disabled altogether by passing the ``--no-qt-log ``
4749to the command line, which will fallback to the default Qt bahavior of printing
4850emitted messages directly to ``stderr ``:
@@ -64,7 +66,7 @@ emitted messages directly to ``stderr``:
6466 this is a WARNING message
6567
6668
67- ``pytest-qt `` also provides a ``qtlog `` fixture, which tests can use
69+ ``pytest-qt `` also provides a ``qtlog `` fixture that can used
6870to check if certain messages were emitted during a test::
6971
7072 def do_something():
@@ -75,10 +77,30 @@ to check if certain messages were emitted during a test::
7577 emitted = [(m.type, m.message.strip()) for m in qtlog.records]
7678 assert emitted == [(QtWarningMsg, 'this is a WARNING message')]
7779
78- Keep in mind that when ``--no-qt-log `` is passed in the command line,
79- ``qtlog.records `` will always be an empty list. See
80- :class: `Record <pytestqt.plugin.Record> ` for reference documentation on
81- ``Record `` objects.
80+
81+ ``qtlog.records `` is a list of :class: `Record <pytestqt.plugin.Record> `
82+ instances.
83+
84+ Logging can also be disabled on a block of code using the ``qtlog.disabled() ``
85+ context manager, or with the ``pytest.mark.no_qt_log `` mark:
86+
87+ .. code-block :: python
88+
89+ def test_foo (qtlog ):
90+ with qtlog.disabled():
91+ # logging is disable within the context manager
92+ do_something()
93+
94+ @pytest.mark.no_qt_log
95+ def test_bar ():
96+ # logging disabled for the entire test
97+ do_something()
98+
99+
100+ Keep in mind that when logging is disabled,
101+ ``qtlog.records `` will always be an empty list.
102+
103+ **Log Formatting **
82104
83105The output format of the messages can also be controlled by using the
84106``--qt-log-format `` command line option, which accepts a string with standard
0 commit comments