summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2006-10-10 12:42:09 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2006-10-10 12:42:09 +0200
commit4d0d4f2fea2aaade1c9903de048a2d6e482d5826 (patch)
treee23956efeebac78543d8d4563a3ff550cf48a20a /bin
parenta04528d15983a4272cb87295a8016365aedb99c8 (diff)
downloadlogilab-common-4d0d4f2fea2aaade1c9903de048a2d6e482d5826.tar.gz
make pytest browse recursively the current directory to find tests
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pytest30
1 files changed, 21 insertions, 9 deletions
diff --git a/bin/pytest b/bin/pytest
index 139872b..6038cf6 100755
--- a/bin/pytest
+++ b/bin/pytest
@@ -4,12 +4,24 @@ import os, sys
import os.path as osp
from logilab.common import testlib
-curdir = os.getcwd()
-if osp.exists(osp.join(curdir, '__pkginfo__.py')):
- projdir = osp.abspath(curdir)
-elif osp.exists(osp.join(curdir, '..')):
- projdir = osp.abspath(osp.join(curdir, '..'))
-else:
- print 'fixme: cannot be run from here.'
- sys.exit(1)
-testlib.main(osp.join(projdir,'test'))
+
+def autopath(projdir=os.getcwd()):
+ """try to find project's root and add it to sys.path"""
+ curdir = osp.abspath(projdir)
+ while not osp.isfile(osp.join(curdir, '__pkginfo__.py')):
+ newdir = osp.normpath(osp.join(curdir, os.pardir))
+ if newdir == curdir:
+ break
+ curdir = newdir
+ else:
+ sys.path.insert(0, curdir)
+
+autopath()
+
+for dirname, dirs, files in os.walk(os.getcwd()):
+ for skipped in ('CVS', '.svn', '.hg'):
+ if skipped in dirs:
+ dirs.remove(skipped)
+ basename = osp.basename(dirname)
+ if basename in ('test', 'tests'):
+ testlib.main(dirname, exitafter=False)