- add request.node which maps to the collection node as specified by the scope.

- remove request.markers which is now available via request.node.markers
This commit is contained in:
holger krekel 2012-09-17 20:43:37 +02:00
parent c2480f5c54
commit 631d311e89
3 changed files with 12 additions and 10 deletions

View File

@ -1,9 +1,11 @@
Changes between 2.2.4 and 2.3.0.dev Changes between 2.2.4 and 2.3.0.dev
----------------------------------- -----------------------------------
- introduce a generic "markers" object on Nodes and request objects - introduce a generic "markers" object on Nodes and a request.node
to allow for reading and manipulation of MarkInfo objects previously attribute pointing to the scope-specific collection node of a request.
set with calls to pytest.mark.* classes. 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 issue185 monkeypatching time.time does not cause pytest to fail
- fix issue172 duplicate call of pytest.setup-decoratored setup_module - fix issue172 duplicate call of pytest.setup-decoratored setup_module
functions functions

View File

@ -962,8 +962,9 @@ class FuncargRequest:
self._factorystack = [] self._factorystack = []
@property @property
def markers(self): def node(self):
return self._getscopeitem(self.scope).markers """ underlying collection node (depends on request scope)"""
return self._getscopeitem(self.scope)
def _getfaclist(self, argname): def _getfaclist(self, argname):
facdeflist = self._name2factory.get(argname, None) facdeflist = self._name2factory.get(argname, None)
@ -1017,7 +1018,7 @@ class FuncargRequest:
@property @property
def keywords(self): def keywords(self):
""" dictionary of markers (readonly). """ """ (deprecated, use node.markers class) dictionary of markers. """
return self._pyfuncitem.keywords return self._pyfuncitem.keywords
@property @property
@ -1051,8 +1052,7 @@ class FuncargRequest:
""" """
if not isinstance(marker, py.test.mark.XYZ.__class__): if not isinstance(marker, py.test.mark.XYZ.__class__):
raise ValueError("%r is not a py.test.mark.* object") raise ValueError("%r is not a py.test.mark.* object")
setattr(self.markers, marker.markname, marker) setattr(self.node.markers, marker.markname, marker)
#self._pyfuncitem.keywords[marker.markname] = marker
def raiseerror(self, msg): def raiseerror(self, msg):
""" raise a FuncargLookupError with the given message. """ """ raise a FuncargLookupError with the given message. """

View File

@ -741,7 +741,7 @@ class TestMarking:
import pytest import pytest
@pytest.factory() @pytest.factory()
def markers(request): def markers(request):
return request.markers return request.node.markers
@pytest.mark.XYZ @pytest.mark.XYZ
def test_function(markers): def test_function(markers):
assert markers.XYZ is not None assert markers.XYZ is not None
@ -755,7 +755,7 @@ class TestMarking:
import pytest import pytest
@pytest.factory() @pytest.factory()
def markers(request): def markers(request):
return request.markers return request.node.markers
@pytest.setup(scope="class") @pytest.setup(scope="class")
def marking(request): def marking(request):