From 3582e1f6bedf5007a8936de71f5865d9a2192822 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 5 Apr 2018 18:46:33 +0200 Subject: [PATCH] include more detail on the marker api issues --- doc/en/mark.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/en/mark.rst b/doc/en/mark.rst index bf1584bf0..2b84037bf 100644 --- a/doc/en/mark.rst +++ b/doc/en/mark.rst @@ -40,7 +40,16 @@ Marker iteration pytest's marker implementation traditionally worked by simply updating the ``__dict__`` attribute of functions to add markers, in a cumulative manner. As a result of the this, markers would unintendely be passed along class hierarchies in surprising ways plus the API for retriving them was inconsistent, as markers from parameterization would be stored differently than markers applied using the ``@pytest.mark`` decorator and markers added via ``node.add_marker``. -This state of things made it technically next to impossible to use data from markers correctly (``args`` and ``kwargs``) without having a deep understanding of the internals, leading to subtle and hard to understand bugs in more advanced usages. +This state of things made it technically next to impossible to use data from markers correctly without having a deep understanding of the internals, leading to subtle and hard to understand bugs in more advanced usages. + +Depending on how a marker got declared/changed one would get either a `MarkerInfo` which might contain markers from siebling classes, +MarkDecroators when marks came from parameterization or from a `add_marker` call, while discarding prior marks. + +Also MarkerInfo acts like a single mark, when it in fact repressents a merged view on multiple marks with the same name. + +On top of that markers where not accessible the same way for modules, classes, and functions/methods, +in fact, markers where only accessible in functions, even if they where declared on classes/modules + A new API to access markers has been introduced in pytest 3.6 in order to solve the problems with the initial design, providing :func:`_pytest.nodes.Node.iter_markers` method to iterate over markers in a consistent manner and reworking the internals, which solved great deal of problems with the initial design.