[py-svn] commit/pytest: hpk42: - add request.node which maps to the collection node as specified by the scope.

Bitbucket commits-noreply at bitbucket.org
Mon Sep 17 20:43:55 CEST 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/2bfd9f1d38e9/
changeset:   2bfd9f1d38e9
user:        hpk42
date:        2012-09-17 20:43:37
summary:     - 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
affected #:  3 files

diff -r ea10a307d8bcee96d40ad50d67d77e67c111c2c9 -r 2bfd9f1d38e92844576df3e71fee49a76c208637 CHANGELOG
--- 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 -r ea10a307d8bcee96d40ad50d67d77e67c111c2c9 -r 2bfd9f1d38e92844576df3e71fee49a76c208637 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -962,8 +962,9 @@
         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 @@
 
     @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 @@
         """
         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 -r ea10a307d8bcee96d40ad50d67d77e67c111c2c9 -r 2bfd9f1d38e92844576df3e71fee49a76c208637 testing/test_python.py
--- a/testing/test_python.py
+++ b/testing/test_python.py
@@ -741,7 +741,7 @@
             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 @@
             import pytest
             @pytest.factory()
             def markers(request):
-                return request.markers
+                return request.node.markers
 
             @pytest.setup(scope="class")
             def marking(request):

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list