diff options
author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2006-10-10 12:42:09 +0200 |
---|---|---|
committer | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2006-10-10 12:42:09 +0200 |
commit | 4d0d4f2fea2aaade1c9903de048a2d6e482d5826 (patch) | |
tree | e23956efeebac78543d8d4563a3ff550cf48a20a /bin | |
parent | a04528d15983a4272cb87295a8016365aedb99c8 (diff) | |
download | logilab-common-4d0d4f2fea2aaade1c9903de048a2d6e482d5826.tar.gz |
make pytest browse recursively the current directory to find tests
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pytest | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -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) |