Debian Codegraph @

doc/en/example/markers.rst

raw
1
2 .. _`mark examples`:
3
4 Working with custom markers
5 =================================================
6
7 Here are some examples using the :ref:`mark` mechanism.
8
9 .. _`mark run`:
10
11 Marking test functions and selecting them for a run
12 ----------------------------------------------------
13
14 You can "mark" a test function with custom metadata like this:
15
16 .. code-block:: python
17
18 # content of test_server.py
19
20 import pytest
21
22
23 @pytest.mark.webtest
24 def test_send_http():
25 pass # perform some webtest test for your app
26
27
28 @pytest.mark.device(serial="123")
29 def test_something_quick():
30 pass
31
32
33 @pytest.mark.device(serial="abc")
34 def test_another():
35 pass
36
37
38 class TestClass:
39 def test_method(self):
40 pass
41
42
43
44 You can then restrict a test run to only run tests marked with ``webtest``:
45
46 .. code-block:: pytest
47
48 $ pytest -v -m webtest
49 =========================== test session starts ============================
50 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
51 cachedir: .pytest_cache
52 rootdir: /home/sweet/project
53 collecting ... collected 4 items / 3 deselected / 1 selected
54
55 test_server.py::test_send_http PASSED [100%]
56
57 ===================== 1 passed, 3 deselected in 0.12s ======================
58
59 Or the inverse, running all tests except the webtest ones:
60
61 .. code-block:: pytest
62
63 $ pytest -v -m "not webtest"
64 =========================== test session starts ============================
65 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
66 cachedir: .pytest_cache
67 rootdir: /home/sweet/project
68 collecting ... collected 4 items / 1 deselected / 3 selected
69
70 test_server.py::test_something_quick PASSED [ 33%]
71 test_server.py::test_another PASSED [ 66%]
72 test_server.py::TestClass::test_method PASSED [100%]
73
74 ===================== 3 passed, 1 deselected in 0.12s ======================
75
76 .. _`marker_keyword_expression_example`:
77
78 Additionally, you can restrict a test run to only run tests matching one or multiple marker
79 keyword arguments, e.g. to run only tests marked with ``device`` and the specific ``serial="123"``:
80
81 .. code-block:: pytest
82
83 $ pytest -v -m "device(serial='123')"
84 =========================== test session starts ============================
85 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
86 cachedir: .pytest_cache
87 rootdir: /home/sweet/project
88 collecting ... collected 4 items / 3 deselected / 1 selected
89
90 test_server.py::test_something_quick PASSED [100%]
91
92 ===================== 1 passed, 3 deselected in 0.12s ======================
93
94 .. note:: Only keyword argument matching is supported in marker expressions.
95
96 .. note:: Only :class:`int`, (unescaped) :class:`str`, :class:`bool` & :data:`None` values are supported in marker expressions.
97
98 Selecting tests based on their node ID
99 --------------------------------------
100
101 You can provide one or more :ref:`node IDs <node-id>` as positional
102 arguments to select only specified tests. This makes it easy to select
103 tests based on their module, class, method, or function name:
104
105 .. code-block:: pytest
106
107 $ pytest -v test_server.py::TestClass::test_method
108 =========================== test session starts ============================
109 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
110 cachedir: .pytest_cache
111 rootdir: /home/sweet/project
112 collecting ... collected 1 item
113
114 test_server.py::TestClass::test_method PASSED [100%]
115
116 ============================ 1 passed in 0.12s =============================
117
118 You can also select on the class:
119
120 .. code-block:: pytest
121
122 $ pytest -v test_server.py::TestClass
123 =========================== test session starts ============================
124 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
125 cachedir: .pytest_cache
126 rootdir: /home/sweet/project
127 collecting ... collected 1 item
128
129 test_server.py::TestClass::test_method PASSED [100%]
130
131 ============================ 1 passed in 0.12s =============================
132
133 Or select multiple nodes:
134
135 .. code-block:: pytest
136
137 $ pytest -v test_server.py::TestClass test_server.py::test_send_http
138 =========================== test session starts ============================
139 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
140 cachedir: .pytest_cache
141 rootdir: /home/sweet/project
142 collecting ... collected 2 items
143
144 test_server.py::TestClass::test_method PASSED [ 50%]
145 test_server.py::test_send_http PASSED [100%]
146
147 ============================ 2 passed in 0.12s =============================
148
149 .. _node-id:
150
151 .. note::
152
153 Node IDs are of the form ``module.py::class::method`` or
154 ``module.py::function``. Node IDs control which tests are
155 collected, so ``module.py::class`` will select all test methods
156 on the class. Nodes are also created for each parameter of a
157 parametrized fixture or test, so selecting a parametrized test
158 must include the parameter value, e.g.
159 ``module.py::function[param]``.
160
161 Node IDs for failing tests are displayed in the test summary info
162 when running pytest with the ``-rf`` option. You can also
163 construct Node IDs from the output of ``pytest --collect-only``.
164
165 Using ``-k expr`` to select tests based on their name
166 -------------------------------------------------------
167
168 .. versionadded:: 2.0/2.3.4
169
170 You can use the :option:`-k` command line option to specify an expression
171 which implements a substring match on the test names instead of the
172 exact match on markers that :option:`-m` provides. This makes it easy to
173 select tests based on their names:
174
175 .. versionchanged:: 5.4
176
177 The expression matching is now case-insensitive.
178
179 .. code-block:: pytest
180
181 $ pytest -v -k http # running with the above defined example module
182 =========================== test session starts ============================
183 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
184 cachedir: .pytest_cache
185 rootdir: /home/sweet/project
186 collecting ... collected 4 items / 3 deselected / 1 selected
187
188 test_server.py::test_send_http PASSED [100%]
189
190 ===================== 1 passed, 3 deselected in 0.12s ======================
191
192 And you can also run all tests except the ones that match the keyword:
193
194 .. code-block:: pytest
195
196 $ pytest -k "not send_http" -v
197 =========================== test session starts ============================
198 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
199 cachedir: .pytest_cache
200 rootdir: /home/sweet/project
201 collecting ... collected 4 items / 1 deselected / 3 selected
202
203 test_server.py::test_something_quick PASSED [ 33%]
204 test_server.py::test_another PASSED [ 66%]
205 test_server.py::TestClass::test_method PASSED [100%]
206
207 ===================== 3 passed, 1 deselected in 0.12s ======================
208
209 Or to select "http" and "quick" tests:
210
211 .. code-block:: pytest
212
213 $ pytest -k "http or quick" -v
214 =========================== test session starts ============================
215 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
216 cachedir: .pytest_cache
217 rootdir: /home/sweet/project
218 collecting ... collected 4 items / 2 deselected / 2 selected
219
220 test_server.py::test_send_http PASSED [ 50%]
221 test_server.py::test_something_quick PASSED [100%]
222
223 ===================== 2 passed, 2 deselected in 0.12s ======================
224
225 You can use ``and``, ``or``, ``not`` and parentheses.
226
227
228 In addition to the test's name, :option:`-k` also matches the names of the test's parents (usually, the name of the file and class it's in),
229 attributes set on the test function, markers applied to it or its parents and any :attr:`extra keywords <_pytest.nodes.Node.extra_keyword_matches>`
230 explicitly added to it or its parents.
231
232
233 Registering markers
234 -------------------------------------
235
236
237
238 .. ini-syntax for custom markers:
239
240 Registering markers for your test suite is simple:
241
242 .. code-block:: toml
243
244 # content of pytest.toml
245 [pytest]
246 markers = ["webtest: mark a test as a webtest.", "slow: mark test as slow."]
247
248 Multiple custom markers can be registered, by defining each one in its own line, as shown in above example.
249
250 You can ask which markers exist for your test suite - the list includes our just defined ``webtest`` and ``slow`` markers:
251
252 .. code-block:: pytest
253
254 $ pytest --markers
255 @pytest.mark.webtest: mark a test as a webtest.
256
257 @pytest.mark.slow: mark test as slow.
258
259 @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
260
261 @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
262
263 @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
264
265 @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=strict_xfail): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
266
267 @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
268
269 @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
270
271 @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible. DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.
272
273 @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible. DEPRECATED, use @pytest.hookimpl(trylast=True) instead.
274
275
276 For an example on how to add and work with markers from a plugin, see
277 :ref:`adding a custom marker from a plugin`.
278
279 .. note::
280
281 It is recommended to explicitly register markers so that:
282
283 * There is one place in your test suite defining your markers
284
285 * Asking for existing markers via ``pytest --markers`` gives good output
286
287 * Typos in function markers are treated as an error if you use the :confval:`strict_markers` configuration option.
288
289 .. _`scoped-marking`:
290
291 Marking whole classes or modules
292 ----------------------------------------------------
293
294 You may use ``pytest.mark`` decorators with classes to apply markers to all of
295 its test methods:
296
297 .. code-block:: python
298
299 # content of test_mark_classlevel.py
300 import pytest
301
302
303 @pytest.mark.webtest
304 class TestClass:
305 def test_startup(self):
306 pass
307
308 def test_startup_and_more(self):
309 pass
310
311 This is equivalent to directly applying the decorator to the
312 two test functions.
313
314 To apply marks at the module level, use the :globalvar:`pytestmark` global variable::
315
316 import pytest
317 pytestmark = pytest.mark.webtest
318
319 or multiple markers::
320
321 pytestmark = [pytest.mark.webtest, pytest.mark.slowtest]
322
323
324 Due to legacy reasons, before class decorators were introduced, it is possible to set the
325 :globalvar:`pytestmark` attribute on a test class like this:
326
327 .. code-block:: python
328
329 import pytest
330
331
332 class TestClass:
333 pytestmark = pytest.mark.webtest
334
335 .. _`marking individual tests when using parametrize`:
336
337 Marking individual tests when using parametrize
338 -----------------------------------------------
339
340 When using parametrize, applying a mark will make it apply
341 to each individual test. However it is also possible to
342 apply a marker to an individual test instance:
343
344 .. code-block:: python
345
346 import pytest
347
348
349 @pytest.mark.foo
350 @pytest.mark.parametrize(
351 ("n", "expected"), [(1, 2), pytest.param(1, 3, marks=pytest.mark.bar), (2, 3)]
352 )
353 def test_increment(n, expected):
354 assert n + 1 == expected
355
356 In this example the mark "foo" will apply to each of the three
357 tests, whereas the "bar" mark is only applied to the second test.
358 Skip and xfail marks can also be applied in this way, see :ref:`skip/xfail with parametrize`.
359
360 .. _`adding a custom marker from a plugin`:
361
362 Custom marker and command line option to control test runs
363 ----------------------------------------------------------
364
365 .. regendoc:wipe
366
367 Plugins can provide custom markers and implement specific behaviour
368 based on it. This is a self-contained example which adds a command
369 line option and a parametrized test function marker to run tests
370 specified via named environments:
371
372 .. code-block:: python
373
374 # content of conftest.py
375
376 import pytest
377
378
379 def pytest_addoption(parser):
380 parser.addoption(
381 "-E",
382 action="store",
383 metavar="NAME",
384 help="only run tests matching the environment NAME.",
385 )
386
387
388 def pytest_configure(config):
389 # register an additional marker
390 config.addinivalue_line(
391 "markers", "env(name): mark test to run only on named environment"
392 )
393
394
395 def pytest_runtest_setup(item):
396 envnames = [mark.args[0] for mark in item.iter_markers(name="env")]
397 if envnames:
398 if item.config.getoption("-E") not in envnames:
399 pytest.skip(f"test requires env in {envnames!r}")
400
401 A test file using this local plugin:
402
403 .. code-block:: python
404
405 # content of test_someenv.py
406
407 import pytest
408
409
410 @pytest.mark.env("stage1")
411 def test_basic_db_operation():
412 pass
413
414 and an example invocation specifying a different environment than what
415 the test needs:
416
417 .. code-block:: pytest
418
419 $ pytest -E stage2
420 =========================== test session starts ============================
421 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
422 rootdir: /home/sweet/project
423 collected 1 item
424
425 test_someenv.py s [100%]
426
427 ============================ 1 skipped in 0.12s ============================
428
429 and here is one that specifies exactly the environment needed:
430
431 .. code-block:: pytest
432
433 $ pytest -E stage1
434 =========================== test session starts ============================
435 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
436 rootdir: /home/sweet/project
437 collected 1 item
438
439 test_someenv.py . [100%]
440
441 ============================ 1 passed in 0.12s =============================
442
443 The :option:`--markers` option always gives you a list of available markers:
444
445 .. code-block:: pytest
446
447 $ pytest --markers
448 @pytest.mark.env(name): mark test to run only on named environment
449
450 @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
451
452 @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
453
454 @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
455
456 @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=strict_xfail): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
457
458 @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
459
460 @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
461
462 @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible. DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.
463
464 @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible. DEPRECATED, use @pytest.hookimpl(trylast=True) instead.
465
466
467 .. _`passing callables to custom markers`:
468
469 Passing a callable to custom markers
470 --------------------------------------------
471
472 .. regendoc:wipe
473
474 Below is the config file that will be used in the next examples:
475
476 .. code-block:: python
477
478 # content of conftest.py
479 import sys
480
481
482 def pytest_runtest_setup(item):
483 for marker in item.iter_markers(name="my_marker"):
484 print(marker)
485 sys.stdout.flush()
486
487 A custom marker can have its argument set, i.e. ``args`` and ``kwargs`` properties, defined by either invoking it as a callable or using ``pytest.mark.MARKER_NAME.with_args``. These two methods achieve the same effect most of the time.
488
489 However, if there is a callable as the single positional argument with no keyword arguments, using the ``pytest.mark.MARKER_NAME(c)`` will not pass ``c`` as a positional argument but decorate ``c`` with the custom marker (see :ref:`MarkDecorator <mark>`). Fortunately, ``pytest.mark.MARKER_NAME.with_args`` comes to the rescue:
490
491 .. code-block:: python
492
493 # content of test_custom_marker.py
494 import pytest
495
496
497 def hello_world(*args, **kwargs):
498 return "Hello World"
499
500
501 @pytest.mark.my_marker.with_args(hello_world)
502 def test_with_args():
503 pass
504
505 The output is as follows:
506
507 .. code-block:: pytest
508
509 $ pytest -q -s
510 Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef0001>,), kwargs={})
511 .
512 1 passed in 0.12s
513
514 We can see that the custom marker has its argument set extended with the function ``hello_world``. This is the key difference between creating a custom marker as a callable, which invokes ``__call__`` behind the scenes, and using ``with_args``.
515
516
517 Reading markers which were set from multiple places
518 ----------------------------------------------------
519
520 .. versionadded: 2.2.2
521
522 .. regendoc:wipe
523
524 If you are heavily using markers in your test suite you may encounter the case where a marker is applied several times to a test function. From plugin
525 code you can read over all such settings. Example:
526
527 .. code-block:: python
528
529 # content of test_mark_three_times.py
530 import pytest
531
532 pytestmark = pytest.mark.glob("module", x=1)
533
534
535 @pytest.mark.glob("class", x=2)
536 class TestClass:
537 @pytest.mark.glob("function", x=3)
538 def test_something(self):
539 pass
540
541 Here we have the marker "glob" applied three times to the same
542 test function. From a conftest file we can read it like this:
543
544 .. code-block:: python
545
546 # content of conftest.py
547 import sys
548
549
550 def pytest_runtest_setup(item):
551 for mark in item.iter_markers(name="glob"):
552 print(f"glob args={mark.args} kwargs={mark.kwargs}")
553 sys.stdout.flush()
554
555 Let's run this without capturing output and see what we get:
556
557 .. code-block:: pytest
558
559 $ pytest -q -s
560 glob args=('function',) kwargs={'x': 3}
561 glob args=('class',) kwargs={'x': 2}
562 glob args=('module',) kwargs={'x': 1}
563 .
564 1 passed in 0.12s
565
566 Marking platform specific tests with pytest
567 --------------------------------------------------------------
568
569 .. regendoc:wipe
570
571 Consider you have a test suite which marks tests for particular platforms,
572 namely ``pytest.mark.darwin``, ``pytest.mark.win32`` etc. and you
573 also have tests that run on all platforms and have no specific
574 marker. If you now want to have a way to only run the tests
575 for your particular platform, you could use the following plugin:
576
577 .. code-block:: python
578
579 # content of conftest.py
580 #
581 import sys
582
583 import pytest
584
585 ALL = set("darwin linux win32".split())
586
587
588 def pytest_runtest_setup(item):
589 supported_platforms = ALL.intersection(mark.name for mark in item.iter_markers())
590 plat = sys.platform
591 if supported_platforms and plat not in supported_platforms:
592 pytest.skip(f"cannot run on platform {plat}")
593
594 then tests will be skipped if they were specified for a different platform.
595 Let's do a little test file to show how this looks like:
596
597 .. code-block:: python
598
599 # content of test_plat.py
600
601 import pytest
602
603
604 @pytest.mark.darwin
605 def test_if_apple_is_evil():
606 pass
607
608
609 @pytest.mark.linux
610 def test_if_linux_works():
611 pass
612
613
614 @pytest.mark.win32
615 def test_if_win32_crashes():
616 pass
617
618
619 def test_runs_everywhere():
620 pass
621
622 then you will see two tests skipped and two executed tests as expected:
623
624 .. code-block:: pytest
625
626 $ pytest -rs # this option reports skip reasons
627 =========================== test session starts ============================
628 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
629 rootdir: /home/sweet/project
630 collected 4 items
631
632 test_plat.py s.s. [100%]
633
634 ========================= short test summary info ==========================
635 SKIPPED [2] conftest.py:13: cannot run on platform linux
636 ======================= 2 passed, 2 skipped in 0.12s =======================
637
638 Note that if you specify a platform via the marker-command line option like this:
639
640 .. code-block:: pytest
641
642 $ pytest -m linux
643 =========================== test session starts ============================
644 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
645 rootdir: /home/sweet/project
646 collected 4 items / 3 deselected / 1 selected
647
648 test_plat.py . [100%]
649
650 ===================== 1 passed, 3 deselected in 0.12s ======================
651
652 then the unmarked-tests will not be run. It is thus a way to restrict the run to the specific tests.
653
654 Automatically adding markers based on test names
655 --------------------------------------------------------
656
657 .. regendoc:wipe
658
659 If you have a test suite where test function names indicate a certain
660 type of test, you can implement a hook that automatically defines
661 markers so that you can use the :option:`-m` option with it. Let's look
662 at this test module:
663
664 .. code-block:: python
665
666 # content of test_module.py
667
668
669 def test_interface_simple():
670 assert 0
671
672
673 def test_interface_complex():
674 assert 0
675
676
677 def test_event_simple():
678 assert 0
679
680
681 def test_something_else():
682 assert 0
683
684 We want to dynamically define two markers and can do it in a
685 ``conftest.py`` plugin:
686
687 .. code-block:: python
688
689 # content of conftest.py
690
691 import pytest
692
693
694 def pytest_collection_modifyitems(items):
695 for item in items:
696 if "interface" in item.nodeid:
697 item.add_marker(pytest.mark.interface)
698 elif "event" in item.nodeid:
699 item.add_marker(pytest.mark.event)
700
701 We can now use the ``-m option`` to select one set:
702
703 .. code-block:: pytest
704
705 $ pytest -m interface --tb=short
706 =========================== test session starts ============================
707 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
708 rootdir: /home/sweet/project
709 collected 4 items / 2 deselected / 2 selected
710
711 test_module.py FF [100%]
712
713 ================================= FAILURES =================================
714 __________________________ test_interface_simple ___________________________
715 test_module.py:4: in test_interface_simple
716 assert 0
717 E assert 0
718 __________________________ test_interface_complex __________________________
719 test_module.py:8: in test_interface_complex
720 assert 0
721 E assert 0
722 ========================= short test summary info ==========================
723 FAILED test_module.py::test_interface_simple - assert 0
724 FAILED test_module.py::test_interface_complex - assert 0
725 ===================== 2 failed, 2 deselected in 0.12s ======================
726
727 or to select both "event" and "interface" tests:
728
729 .. code-block:: pytest
730
731 $ pytest -m "interface or event" --tb=short
732 =========================== test session starts ============================
733 platform linux -- Python 3.x.y, pytest-9.x.y, pluggy-1.x.y
734 rootdir: /home/sweet/project
735 collected 4 items / 1 deselected / 3 selected
736
737 test_module.py FFF [100%]
738
739 ================================= FAILURES =================================
740 __________________________ test_interface_simple ___________________________
741 test_module.py:4: in test_interface_simple
742 assert 0
743 E assert 0
744 __________________________ test_interface_complex __________________________
745 test_module.py:8: in test_interface_complex
746 assert 0
747 E assert 0
748 ____________________________ test_event_simple _____________________________
749 test_module.py:12: in test_event_simple
750 assert 0
751 E assert 0
752 ========================= short test summary info ==========================
753 FAILED test_module.py::test_interface_simple - assert 0
754 FAILED test_module.py::test_interface_complex - assert 0
755 FAILED test_module.py::test_event_simple - assert 0
756 ===================== 3 failed, 1 deselected in 0.12s ======================