summaryrefslogtreecommitdiff
path: root/nose/util.py
diff options
context:
space:
mode:
authorJason Pellerin <jpellerin@gmail.com>2007-03-23 22:38:46 +0000
committerJason Pellerin <jpellerin@gmail.com>2007-03-23 22:38:46 +0000
commit178e3c13ab7ea3f8b84ce1b85ace76aa845e8e4b (patch)
tree67a4f9a7a7a441f6feb9cab42cbba63b91cb4b6a /nose/util.py
parentb9b9dcadd6a1d34aac58b4d9ea5d623aab8cbe3e (diff)
downloadnose-178e3c13ab7ea3f8b84ce1b85ace76aa845e8e4b.tar.gz
Work in progress on moving more of the context functionality into the context suite/factory
Diffstat (limited to 'nose/util.py')
-rw-r--r--nose/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nose/util.py b/nose/util.py
index 85087e7..26795dd 100644
--- a/nose/util.py
+++ b/nose/util.py
@@ -136,6 +136,21 @@ def ispackage(path):
return True
return False
+def getfilename(package, relativeTo=None):
+ """Find the python source file for a package, relative to a
+ particular directory (defaults to current working directory if not
+ given).
+ """
+ if relativeTo is None:
+ relativeTo = os.getcwd()
+ path = os.path.join(relativeTo, os.sep.join(package.split('.')))
+ suffixes = ('/__init__.py', '.py')
+ for suffix in suffixes:
+ filename = path + suffix
+ if os.path.exists(filename):
+ return filename
+ return None
+
def getpackage(filename):
"""
Find the full dotted package name for a given python source file