@@ -25,10 +25,12 @@ You can "mark" a test function with custom metadata like this:
25
25
pass # perform some webtest test for your app
26
26
27
27
28
+ @pytest.mark.device (serial = " 123" )
28
29
def test_something_quick ():
29
30
pass
30
31
31
32
33
+ @pytest.mark.device (serial = " abc" )
32
34
def test_another ():
33
35
pass
34
36
@@ -71,6 +73,28 @@ Or the inverse, running all tests except the webtest ones:
71
73
72
74
===================== 3 passed, 1 deselected in 0.12s ======================
73
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-8.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 ``int``, (unescaped) ``str``, ``bool`` & ``None`` values are supported in marker expressions.
97
+
74
98
Selecting tests based on their node ID
75
99
--------------------------------------
76
100
0 commit comments