diff options
author | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2010-03-22 17:19:28 +0100 |
---|---|---|
committer | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2010-03-22 17:19:28 +0100 |
commit | 012d593469c184f48754b560027a813eb57dd048 (patch) | |
tree | 3186030343fe6a4fd468024ebb95a93f484e7add | |
parent | 190fb7de198047b745d00b9f43abc414caa05f32 (diff) | |
download | logilab-common-012d593469c184f48754b560027a813eb57dd048.tar.gz |
allow multiple arguments for logilab.common.testlib.TestCase.datapath.\n\ndatapath now handle multiple argument as os.path.join do
-rw-r--r-- | test/unittest_testlib.py | 5 | ||||
-rw-r--r-- | testlib.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py index 152ccc7..19aa281 100644 --- a/test/unittest_testlib.py +++ b/test/unittest_testlib.py @@ -221,6 +221,11 @@ class TestlibTC(TestCase): self.assertEquals(self.datadir, expected_datadir) self.assertEquals(self.datapath('foo'), join(expected_datadir, 'foo')) + def test_multiple_args_datadir(self): + expected_datadir = join(dirname(abspath(__file__)), 'data') + self.assertEquals(self.datadir, expected_datadir) + self.assertEquals(self.datapath('foo', 'bar'), join(expected_datadir, 'foo', 'bar')) + def test_custom_datadir(self): class MyTC(TestCase): datadir = 'foo' @@ -1010,9 +1010,9 @@ class TestCase(unittest.TestCase): # instantiated for each test run) datadir = classproperty(cached(datadir)) - def datapath(cls, fname): + def datapath(cls, *fname): """joins the object's datadir and `fname`""" - return osp.join(cls.datadir, fname) + return osp.join(cls.datadir, *fname) datapath = classmethod(datapath) def set_description(self, descr): |