_pytest.mark.structures module¶
-
class
ParameterSet
(values, marks, id)[source]¶ Bases:
_pytest.mark.structures.ParameterSet
-
classmethod
extract_from
(parameterset, force_tuple=False)[source]¶ - Parameters
parameterset – a legacy style parameterset that may or may not be a tuple, and may or may not be wrapped into a mess of mark objects
force_tuple – enforce tuple wrapping so single argument tuple values don’t get decomposed and break tests
-
classmethod
-
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
¶
-
normalize_mark_list
(mark_list: Iterable[Union[_pytest.mark.structures.Mark, _pytest.mark.structures.MarkDecorator]]) → List[_pytest.mark.structures.Mark][source]¶ normalizes marker decorating helpers to mark objects
- Return type
List[Mark]
-
store_mark
(obj, mark)[source]¶ store a Mark on an object this is used to implement the Mark declarations/decorators correctly
-
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¶
-