summaryrefslogtreecommitdiff
path: root/pytest.py
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-04-17 17:14:02 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-04-17 17:14:02 +0200
commitad4456b25e584fc9a14275549d2dfba5564b081b (patch)
tree30c17b261ce607fd7636b9467e21fb3b71f7e941 /pytest.py
parenta4a8ed0ab4104ce1cfcc278d39864f11f97ea045 (diff)
downloadlogilab-common-ad4456b25e584fc9a14275549d2dfba5564b081b.tar.gz
only store tracebacks in pdbmode
Diffstat (limited to 'pytest.py')
-rw-r--r--pytest.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/pytest.py b/pytest.py
index 5f34674..e2eecca 100644
--- a/pytest.py
+++ b/pytest.py
@@ -60,7 +60,6 @@ def autopath(projdir=os.getcwd()):
else:
sys.path.insert(0, curdir)
sys.path.insert(0, '')
- return curdir
class GlobalTestReport(object):
@@ -219,6 +218,7 @@ def parseargs():
def rebuild_cmdline(option, opt, value, parser):
"""carry the option to unittest_main"""
newargs.append(opt)
+
def rebuild_and_store(option, opt, value, parser):
"""carry the option to unittest_main and store
@@ -235,8 +235,9 @@ def parseargs():
# unittest_main options provided and passed through pytest
parser.add_option('-v', '--verbose', callback=rebuild_cmdline,
action="callback", help="Verbose output")
- parser.add_option('-i', '--pdb', callback=rebuild_cmdline,
- action="callback", help="Enable test failure inspection")
+ parser.add_option('-i', '--pdb', callback=rebuild_and_store,
+ dest="pdb", action="callback",
+ help="Enable test failure inspection (conflicts with --coverage)")
parser.add_option('-x', '--exitfirst', callback=rebuild_and_store,
dest="exitfirst",
action="callback", help="Exit on first failure "
@@ -268,10 +269,13 @@ def parseargs():
pass
else:
parser.add_option('--coverage', dest="coverage", default=False,
- action="store_true", help="run tests with pycoverage")
+ action="store_true",
+ help="run tests with pycoverage (conflicts with --pdb)")
# parse the command line
options, args = parser.parse_args()
+ if options.pdb and getattr(options, 'coverage', False):
+ parser.error("'pdb' and 'coverage' options are exclusive")
filenames = [arg for arg in args if arg.endswith('.py')]
if filenames:
if len(filenames) > 1:
@@ -293,7 +297,7 @@ def parseargs():
def run():
- rootdir = autopath()
+ autopath()
tester = PyTester()
options, newargs, explicitfile = parseargs()
# mock a new command line
@@ -312,7 +316,7 @@ def run():
else:
tester.testall(options.exitfirst)
finally:
- errcode = tester.
+ errcode = tester.show_report()
if covermode:
here = osp.abspath(os.getcwd())
if this_is_a_testdir(here):
@@ -322,8 +326,6 @@ def run():
print "computing code coverage (%s), this might thake some time" % \
morfdir
cvg.save()
- executed = [fname for fname in cvg.cexecuted if fname.startswith(morfdir)
- if osp.isfile(fname)]
- cvg.annotate(executed)
- cvg.report(executed, False)
+ cvg.annotate([morfdir])
+ cvg.report([morfdir], False)
sys.exit(errcode)