summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2009-07-22 00:34:00 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2009-07-22 00:34:00 +0200
commit4c6e3212cf1edef7a237feea099804c20653dd0b (patch)
tree4f3b9dbd24d551f5947d09bd675c91eaf366e940
parent45906fef7baab64a184f6bd44b5e24e91ecee5bd (diff)
parentd2a42fc7f36930a2eecb406f35cd1eabc5d3e9e8 (diff)
downloadlogilab-common-4c6e3212cf1edef7a237feea099804c20653dd0b.tar.gz
merge
-rw-r--r--decorators.py2
-rw-r--r--testlib.py21
2 files changed, 7 insertions, 16 deletions
diff --git a/decorators.py b/decorators.py
index 1eafb47..d7768a0 100644
--- a/decorators.py
+++ b/decorators.py
@@ -99,6 +99,8 @@ class wproperty(object):
class classproperty(object):
+ """this is a simple property-like class but for class attributes.
+ """
def __init__(self, get):
self.get = get
def __get__(self, inst, cls):
diff --git a/testlib.py b/testlib.py
index b9d1b80..22526c2 100644
--- a/testlib.py
+++ b/testlib.py
@@ -62,7 +62,7 @@ from logilab.common.compat import set, enumerate, any, sorted
# pylint: enable-msg=W0622
from logilab.common.modutils import load_module_from_name
from logilab.common.debugger import Debugger, colorize_source
-from logilab.common.decorators import cached
+from logilab.common.decorators import cached, classproperty
from logilab.common import textutils
@@ -1056,18 +1056,6 @@ class InnerTest(tuple):
instance.name = name
return instance
-class ClassGetProperty(object):
- """this is a simple property-like class but for
- class attributes.
- """
-
- def __init__(self, getter):
- self.getter = getter
-
- def __get__(self, obj, objtype): # pylint: disable-msg=W0613
- "__get__(objn objtype) -> objtype"
- return self.getter(objtype)
-
class TestCase(unittest.TestCase):
"""unittest.TestCase with some additional methods"""
@@ -1100,11 +1088,12 @@ class TestCase(unittest.TestCase):
return osp.join(osp.dirname(osp.abspath(mod.__file__)), 'data')
# cache it (use a class method to cache on class since TestCase is
# instantiated for each test run)
- datadir = ClassGetProperty(cached(datadir))
+ datadir = classproperty(cached(datadir))
- def datapath(self, fname):
+ def datapath(cls, fname):
"""joins the object's datadir and `fname`"""
- return osp.join(self.datadir, fname)
+ return osp.join(cls.datadir, fname)
+ datapath = classmethod(datapath)
def set_description(self, descr):
"""sets the current test's description.