From 456a72762dba322282be49fbb7c6ef522cacb369 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Sun, 14 Jan 2007 16:56:23 +1100 Subject: Add sibpath --- python/subunit/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'python/subunit/__init__.py') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index d97a15b..caab176 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -27,6 +27,11 @@ def test_suite(): import subunit.tests return subunit.tests.test_suite() + +def sibpath(path, sibling): + return os.path.join(os.path.dirname(os.path.abspath(path)), sibling) + + class TestProtocolServer(object): """A class for receiving results from a TestProtocol client.""" -- cgit v1.2.1 From 501ba57871b35bab0bce1da4b72f7990a4f9dc14 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Sun, 14 Jan 2007 17:02:10 +1100 Subject: Make ExecTestCase test docstring/paths relative to the module they are defined in. --- python/subunit/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python/subunit/__init__.py') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index caab176..f56f724 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -283,7 +283,8 @@ class ExecTestCase(unittest.TestCase): """ unittest.TestCase.__init__(self, methodName) testMethod = getattr(self, methodName) - self.script = testMethod.__doc__ + self.script = sibpath(sys.modules[self.__class__.__module__].__file__, + testMethod.__doc__) def countTestCases(self): return 1 -- cgit v1.2.1 From cb1a0a2e928473ea68649c09b3691886ac93b57a Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Sun, 14 Jan 2007 17:33:52 +1100 Subject: Rename sibpath to join_dir, and add a docstring. --- python/subunit/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'python/subunit/__init__.py') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index f56f724..7a04eb9 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -28,8 +28,18 @@ def test_suite(): return subunit.tests.test_suite() -def sibpath(path, sibling): - return os.path.join(os.path.dirname(os.path.abspath(path)), sibling) +def join_dir(base_path, path): + """ + Returns an absolute path to C{path}, calculated relative to the parent + of C{base_path}. + + @param base_path: A path to a file or directory. + @param path: An absolute path, or a path relative to the containing + directory of C{base_path}. + + @return: An absolute path to C{path}. + """ + return os.path.join(os.path.dirname(os.path.abspath(base_path)), path) class TestProtocolServer(object): @@ -283,8 +293,8 @@ class ExecTestCase(unittest.TestCase): """ unittest.TestCase.__init__(self, methodName) testMethod = getattr(self, methodName) - self.script = sibpath(sys.modules[self.__class__.__module__].__file__, - testMethod.__doc__) + self.script = join_dir(sys.modules[self.__class__.__module__].__file__, + testMethod.__doc__) def countTestCases(self): return 1 -- cgit v1.2.1