You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/example/markers.rst
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,7 +330,7 @@ specifies via named environments::
330
330
"env(name): mark test to run only on named environment")
331
331
332
332
def pytest_runtest_setup(item):
333
-
envnames = [mark.args[0] for mark in item.iter_markers() if mark.name == "env"]
333
+
envnames = [mark.args[0] for mark in item.iter_markers(name='env')]
334
334
if envnames:
335
335
if item.config.getoption("-E") not in envnames:
336
336
pytest.skip("test requires env in %r" % envnames)
@@ -402,10 +402,9 @@ Below is the config file that will be used in the next examples::
402
402
import sys
403
403
404
404
def pytest_runtest_setup(item):
405
-
for marker in item.iter_markers():
406
-
if marker.name == 'my_marker':
407
-
print(marker)
408
-
sys.stdout.flush()
405
+
for marker in item.iter_markers(name='my_marker'):
406
+
print(marker)
407
+
sys.stdout.flush()
409
408
410
409
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.
411
410
@@ -458,10 +457,9 @@ test function. From a conftest file we can read it like this::
0 commit comments