diff options
author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2007-03-07 12:48:16 +0100 |
---|---|---|
committer | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2007-03-07 12:48:16 +0100 |
commit | a6dec5c8d78333788b6251d9f9e996722b94ca6c (patch) | |
tree | f52a4b0391f3ee54e23ec7db364500f8a6cb95dc /pytest.py | |
parent | 0e94b5f7f5def274806d2b2c7bcf71472679b564 (diff) | |
download | logilab-common-a6dec5c8d78333788b6251d9f9e996722b94ca6c.tar.gz |
autopath is now based on __init__.py detection rather than __pkginfo__.py
Diffstat (limited to 'pytest.py')
-rw-r--r-- | pytest.py | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -22,14 +22,14 @@ doctest.DocTestCase.__bases__ = (testlib.TestCase,) 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')): + while osp.isfile(osp.join(curdir, '__init__.py')): newdir = osp.normpath(osp.join(curdir, os.pardir)) if newdir == curdir: break curdir = newdir else: sys.path.insert(0, curdir) - + sys.path.insert(0, '') class GlobalTestReport(object): """this class holds global test statistics""" @@ -107,7 +107,7 @@ def testonedir(testdir, exitfirst=False, report=None): for filename in abspath_listdir(testdir): if this_is_a_testfile(filename): # run test and collect information - prog, ttime, ctime = testfile(filename) + prog, ttime, ctime = testfile(filename, batchmode=True) report.feed(filename, prog.result, ttime, ctime) if exitfirst and not prog.result.wasSuccessful(): break @@ -117,7 +117,7 @@ def testonedir(testdir, exitfirst=False, report=None): return report.failures + report.errors -def testfile(filename): +def testfile(filename, batchmode=False): """runs every test in `filename` :param filename: an absolute path pointing to a unittest file @@ -126,16 +126,16 @@ def testfile(filename): dirname = osp.dirname(filename) if dirname: os.chdir(dirname) - sys.path.insert(0, '') modname = osp.basename(filename)[:-3] try: tstart, cstart = time(), clock() - testprog = testlib.unittest_main(modname, batchmode=True) + testprog = testlib.unittest_main(modname, batchmode) tend, cend = time(), clock() return testprog, (tend - tstart), (cend - cstart) finally: - sys.path.pop(0) - + if dirname: + os.chdir(here) + def parseargs(): """builds an option parser |