_pytest.mark package¶
Module contents¶
generic mechanism for marking and selecting python functions.
-
class
Mark
(name: str, args, kwargs, param_ids_from: Optional[Mark] = None, param_ids_generated: Optional[List[str]] = None)[source]¶ Bases:
object
-
name
¶ name of the mark
-
args
¶ positional arguments of the mark decorator
-
kwargs
¶ keyword arguments of the mark decorator
-
_param_ids_from
¶ source Mark for ids with parametrize Marks
-
_param_ids_generated
¶ resolved/generated ids with parametrize Marks
-
combined_with
(other: _pytest.mark.structures.Mark) → _pytest.mark.structures.Mark[source]¶ -
combines by appending args and merging the mappings
-
-
class
MarkDecorator
(mark)[source]¶ Bases:
object
A decorator for test functions and test classes. When applied it will create
Mark
objects which are often created like this:mark1 = pytest.mark.NAME # simple MarkDecorator mark2 = pytest.mark.NAME(name1=value) # parametrized MarkDecorator
and can then be applied as decorators to test functions:
@mark2 def test_function(): pass
When a MarkDecorator instance is called it does the following:
If called with a single class as its only positional argument and no additional keyword arguments, it attaches itself to the class so it gets applied automatically to all test cases found in that class.
If called with a single function as its only positional argument and no additional keyword arguments, it attaches a MarkInfo object to the function, containing all the arguments already stored internally in the MarkDecorator.
When called in any other case, it performs a ‘fake construction’ call, i.e. it returns a new MarkDecorator instance with the original MarkDecorator’s content updated with the arguments passed to this call.
Note: The rules above prevent MarkDecorator objects from storing only a single function or class reference as their positional argument with no additional keyword or positional arguments.
-
name
¶ alias for mark.name
-
args
¶ alias for mark.args
-
kwargs
¶ alias for mark.kwargs
-
markname
¶
-
class
MarkGenerator
[source]¶ Bases:
object
Factory for
MarkDecorator
objects - exposed as apytest.mark
singleton instance. Example:import pytest @pytest.mark.slowtest def test_function(): pass
will set a ‘slowtest’
MarkInfo
object on thetest_function
object.-
_config
= None¶
-