--- unittest.py Thu Apr 26 02:46:42 2001 +++ /home/bcsaller/unittest.py Fri May 11 00:44:46 2001 @@ -54,6 +54,7 @@ import string import os import types +import inspect ############################################################################## # Test framework core @@ -143,6 +144,7 @@ method when executed. Raises a ValueError if the instance does not have a method with the specified name. """ + try: self.__testMethodName = methodName testMethod = getattr(self, methodName) @@ -151,6 +153,19 @@ raise ValueError, "no such test method in %s: %s" % \ (self.__class__, methodName) + def getPath(self, file=None): + """Return a path to the directory in which the test is + located. This is useful when the test need to use files as + data, but may be run from a vareity of locations. If called + with an optional argument the directory and the argument will + be joined into the name name of a file""" + if not hasattr(self, "_path"): + self._path = os.path.dirname(inspect.getsourcefile(self.__class__)) + + if file: + return os.path.join(self._path, file) + return self._path + def setUp(self): "Hook method for setting up the test fixture before exercising it." pass