diff --git a/CHANGELOG b/CHANGELOG index 72c780fc0..5a2ea45c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,11 @@ Changes between 2.2.4 and 2.3.0.dev ----------------------------------- -- introduce a generic "markers" object on Nodes and request objects - to allow for reading and manipulation of MarkInfo objects previously - set with calls to pytest.mark.* classes. +- introduce a generic "markers" object on Nodes and a request.node + attribute pointing to the scope-specific collection node of a request. + node.markers allows reading and manipulating of MarkInfo objects + previously attached with @pytest.mark.* or request.applymarker or + setattr(node.markers, name, pytest.mark.*) calls. - fix issue185 monkeypatching time.time does not cause pytest to fail - fix issue172 duplicate call of pytest.setup-decoratored setup_module functions diff --git a/_pytest/python.py b/_pytest/python.py index e569ed50e..48ee6ae7d 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -962,8 +962,9 @@ class FuncargRequest: self._factorystack = [] @property - def markers(self): - return self._getscopeitem(self.scope).markers + def node(self): + """ underlying collection node (depends on request scope)""" + return self._getscopeitem(self.scope) def _getfaclist(self, argname): facdeflist = self._name2factory.get(argname, None) @@ -1017,7 +1018,7 @@ class FuncargRequest: @property def keywords(self): - """ dictionary of markers (readonly). """ + """ (deprecated, use node.markers class) dictionary of markers. """ return self._pyfuncitem.keywords @property @@ -1051,8 +1052,7 @@ class FuncargRequest: """ if not isinstance(marker, py.test.mark.XYZ.__class__): raise ValueError("%r is not a py.test.mark.* object") - setattr(self.markers, marker.markname, marker) - #self._pyfuncitem.keywords[marker.markname] = marker + setattr(self.node.markers, marker.markname, marker) def raiseerror(self, msg): """ raise a FuncargLookupError with the given message. """ diff --git a/testing/test_python.py b/testing/test_python.py index b9644eb87..8ce5e8b50 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -741,7 +741,7 @@ class TestMarking: import pytest @pytest.factory() def markers(request): - return request.markers + return request.node.markers @pytest.mark.XYZ def test_function(markers): assert markers.XYZ is not None @@ -755,7 +755,7 @@ class TestMarking: import pytest @pytest.factory() def markers(request): - return request.markers + return request.node.markers @pytest.setup(scope="class") def marking(request):