@@ -43,6 +43,8 @@ For example:
43
43
1 failed in 0.01 seconds
44
44
45
45
46
+ **Disabling Loggin Capture **
47
+
46
48
Qt logging capture can be disabled altogether by passing the ``--no-qt-log ``
47
49
to the command line, which will fallback to the default Qt bahavior of printing
48
50
emitted messages directly to ``stderr ``:
@@ -64,7 +66,7 @@ emitted messages directly to ``stderr``:
64
66
this is a WARNING message
65
67
66
68
67
- ``pytest-qt `` also provides a ``qtlog `` fixture, which tests can use
69
+ ``pytest-qt `` also provides a ``qtlog `` fixture that can used
68
70
to check if certain messages were emitted during a test::
69
71
70
72
def do_something():
@@ -75,10 +77,30 @@ to check if certain messages were emitted during a test::
75
77
emitted = [(m.type, m.message.strip()) for m in qtlog.records]
76
78
assert emitted == [(QtWarningMsg, 'this is a WARNING message')]
77
79
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 **
82
104
83
105
The output format of the messages can also be controlled by using the
84
106
``--qt-log-format `` command line option, which accepts a string with standard
0 commit comments