_pytest.mark.structures module

istestfunc(func)[source]
get_empty_parameterset_mark(config, argnames, func)[source]
class ParameterSet(values, marks, id)[source]

Bases: _pytest.mark.structures.ParameterSet

classmethod param(*values, marks=(), id=None)[source]
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

staticmethod _parse_parametrize_args(argnames, argvalues, *args, **kwargs)[source]
staticmethod _parse_parametrize_parameters(argvalues, force_tuple)[source]
classmethod _for_parametrize(argnames, argvalues, func, config, function_definition)[source]
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

_has_param_ids()[source]
combined_with(other: _pytest.mark.structures.Mark)_pytest.mark.structures.Mark[source]
Parameters

other (Mark) – the mark to combine with

Return type

Mark

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:

  1. 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.

  2. 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.

  3. 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
with_args(*args, **kwargs)[source]

return a MarkDecorator with extra arguments added

unlike call this can be used even if the sole argument is a callable/class

Returns

MarkDecorator

get_unpacked_marks(obj)[source]

obtain the unpacked marks that are stored on an object

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 a pytest.mark singleton instance. Example:

import pytest
@pytest.mark.slowtest
def test_function():
   pass

will set a ‘slowtest’ MarkInfo object on the test_function object.

_config = None
_markers: Set[str] = {}
class NodeKeywords(node)[source]

Bases: collections.abc.MutableMapping

_seen()[source]
_abc_impl = <_abc_data object>