avoid deprecation warnings for our internal accesses

This commit is contained in:
holger krekel
2011-03-05 14:16:27 +01:00
parent 22fac92ca0
commit 07cee24122
4 changed files with 17 additions and 12 deletions
+8 -3
View File
@@ -121,9 +121,6 @@ class HookProxy:
def compatproperty(name):
def fget(self):
#print "retrieving %r property from %s" %(name, self.fspath)
py.log._apiwarn("2.0", "use pytest.%s for "
"test collection and item classes" % name)
return getattr(pytest, name)
return property(fget, None, None,
"deprecated attribute %r, use pytest.%s" % (name,name))
@@ -157,6 +154,14 @@ class Node(object):
File = compatproperty("File")
Item = compatproperty("Item")
def _getcustomclass(self, name):
cls = getattr(self, name)
if cls != getattr(pytest, name):
py.log._apiwarn("2.0", "use of node.%s is deprecated, "
"use pytest_pycollect_makeitem(...) to create custom "
"collection nodes" % name)
return cls
def __repr__(self):
return "<%s %r>" %(self.__class__.__name__, getattr(self, 'name', None))