summaryrefslogtreecommitdiff
path: root/bin/pytest
blob: 6038cf6b367ceb8aa973380acc9857612b6fa261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python

import os, sys
import os.path as osp
from logilab.common import testlib


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)