@@ -25,10 +25,12 @@ You can "mark" a test function with custom metadata like this:
2525 pass # perform some webtest test for your app
2626
2727
28+ @pytest.mark.device (serial = " 123" )
2829 def test_something_quick ():
2930 pass
3031
3132
33+ @pytest.mark.device (serial = " abc" )
3234 def test_another ():
3335 pass
3436
@@ -71,6 +73,28 @@ Or the inverse, running all tests except the webtest ones:
7173
7274 ===================== 3 passed, 1 deselected in 0.12s ======================
7375
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+
7498Selecting tests based on their node ID
7599--------------------------------------
76100
0 commit comments