[Zope3-checkins]
SVN: zope.testing/trunk/src/zope/testing/testrunner
Fixed a bug in the coverage feature that was exposed by
running tests
Jim Fulton
jim at zope.com
Sun Jan 1 13:41:02 EST 2006
Log message for revision 41060:
Fixed a bug in the coverage feature that was exposed by running tests
in a windows install. The coverage feature didn't work when used to
test code installed in site-packages.
Changed:
U zope.testing/trunk/src/zope/testing/testrunner-coverage.txt
U zope.testing/trunk/src/zope/testing/testrunner.py
-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner-coverage.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-coverage.txt 2005-12-31 19:59:24 UTC (rev 41059)
+++ zope.testing/trunk/src/zope/testing/testrunner-coverage.txt 2006-01-01 18:41:00 UTC (rev 41060)
@@ -19,10 +19,66 @@
>>> from zope.testing import testrunner
>>> testrunner.run(defaults)
Running unit tests:
- ...
+ Ran 192 tests with 0 failures and 0 errors in 0.125 seconds.
+ Running samplelayers.Layer1 tests:
+ Set up samplelayers.Layer1 in 0.000 seconds.
+ Ran 9 tests with 0 failures and 0 errors in 0.003 seconds.
+ Running samplelayers.Layer11 tests:
+ Set up samplelayers.Layer11 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.029 seconds.
+ Running samplelayers.Layer111 tests:
+ Set up samplelayers.Layerx in 0.000 seconds.
+ Set up samplelayers.Layer111 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.024 seconds.
+ Running samplelayers.Layer112 tests:
+ Tear down samplelayers.Layer111 in 0.000 seconds.
+ Set up samplelayers.Layer112 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.024 seconds.
+ Running samplelayers.Layer12 tests:
+ Tear down samplelayers.Layer112 in 0.000 seconds.
+ Tear down samplelayers.Layerx in 0.000 seconds.
+ Tear down samplelayers.Layer11 in 0.000 seconds.
+ Set up samplelayers.Layer12 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.026 seconds.
+ Running samplelayers.Layer121 tests:
+ Set up samplelayers.Layer121 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.025 seconds.
+ Running samplelayers.Layer122 tests:
+ Tear down samplelayers.Layer121 in 0.000 seconds.
+ Set up samplelayers.Layer122 in 0.000 seconds.
+ Ran 34 tests with 0 failures and 0 errors in 0.025 seconds.
+ Tearing down left over layers:
+ Tear down samplelayers.Layer122 in 0.000 seconds.
+ Tear down samplelayers.Layer12 in 0.000 seconds.
+ Tear down samplelayers.Layer1 in 0.000 seconds.
+ Total: 405 tests, 0 failures, 0 errors
lines cov% module (path)
- ... ...% zope.testing.testrunner (src/zope/testing/testrunner.py)
- ...
+ 82 78% sample1.sample11.sampletests (testrunner-ex/sample1/sample11/sampletests.py)
+ 52 92% sample1.sample13.sampletests (testrunner-ex/sample1/sample13/sampletests.py)
+ 52 92% sample1.sampletests.test1 (testrunner-ex/sample1/sampletests/test1.py)
+ 78 94% sample1.sampletests.test11 (testrunner-ex/sample1/sampletests/test11.py)
+ 78 94% sample1.sampletests.test111 (testrunner-ex/sample1/sampletests/test111.py)
+ 78 94% sample1.sampletests.test112 (testrunner-ex/sample1/sampletests/test112.py)
+ 78 94% sample1.sampletests.test12 (testrunner-ex/sample1/sampletests/test12.py)
+ 78 94% sample1.sampletests.test121 (testrunner-ex/sample1/sampletests/test121.py)
+ 78 94% sample1.sampletests.test122 (testrunner-ex/sample1/sampletests/test122.py)
+ 52 92% sample1.sampletests.test_one (testrunner-ex/sample1/sampletests/test_one.py)
+ 52 92% sample1.sampletestsf (testrunner-ex/sample1/sampletestsf.py)
+ 52 92% sample2.sample21.sampletests (testrunner-ex/sample2/sample21/sampletests.py)
+ 52 92% sample2.sampletests.test_1 (testrunner-ex/sample2/sampletests/test_1.py)
+ 52 92% sample2.sampletests.testone (testrunner-ex/sample2/sampletests/testone.py)
+ 52 92% sample3.sampletests (testrunner-ex/sample3/sampletests.py)
+ 96 75% samplelayers (testrunner-ex/samplelayers.py)
+ 52 92% sampletests.test1 (testrunner-ex/sampletests/test1.py)
+ 78 94% sampletests.test11 (testrunner-ex/sampletests/test11.py)
+ 78 94% sampletests.test111 (testrunner-ex/sampletests/test111.py)
+ 80 95% sampletests.test112 (testrunner-ex/sampletests/test112.py)
+ 78 94% sampletests.test12 (testrunner-ex/sampletests/test12.py)
+ 78 94% sampletests.test121 (testrunner-ex/sampletests/test121.py)
+ 78 94% sampletests.test122 (testrunner-ex/sampletests/test122.py)
+ 52 92% sampletests.test_one (testrunner-ex/sampletests/test_one.py)
+ 122 87% sampletestsf (testrunner-ex/sampletestsf.py)
+ False
The directory specified with the --coverage option will have been created and
will hold the coverage reports.
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py 2005-12-31 19:59:24 UTC (rev 41059)
+++ zope.testing/trunk/src/zope/testing/testrunner.py 2006-01-01 18:41:00 UTC (rev 41060)
@@ -45,21 +45,29 @@
real_pdb_set_trace = pdb.set_trace
-class MyIgnore(trace.Ignore):
+class TestIgnore:
+ def __init__(self, options):
+ self._test_dirs = [d[0] + os.path.sep for d in test_dirs(options, {})]
+ self._ignore = {'<string>': 1}
+ self._ignored = self._ignore.get
+
def names(self, filename, modulename):
- if modulename in self._ignore:
- return self._ignore[modulename]
+ ignore = self._ignored(modulename)
+ if ignore is None:
+ ignore = True
+ if filename is not None:
+ for d in self._test_dirs:
+ if filename.startswith(d):
+ ignore = False
+ break
+ self._ignore[modulename] = ignore
+ return ignore
- if filename.startswith('<doctest'):
- self._ignore[modulename] = True
-
- return trace.Ignore.names(self, filename, modulename)
-
-class MyTrace(trace.Trace):
+class TestTrace(trace.Trace):
"""Simple tracer.
- >>> tracer = MyTrace(count=False, trace=False)
+ >>> tracer = TestTrace(None, count=False, trace=False)
Simple rules for use: you can't stop the tracer if it not started
and you can't start the tracer if it already started:
@@ -82,9 +90,10 @@
AssertionError: can't stop if not started
"""
- def __init__(self, *args, **kws):
- trace.Trace.__init__(self, *args, **kws)
- self.ignore = MyIgnore(kws.get("ignoremods"), kws.get("ignoredirs"))
+ def __init__(self, options, **kw):
+ trace.Trace.__init__(self, **kw)
+ if options is not None:
+ self.ignore = TestIgnore(options)
self.started = False
def start(self):
@@ -203,9 +212,7 @@
sys.exit()
if options.coverage:
- tracer = MyTrace(ignoredirs=[sys.prefix, sys.exec_prefix],
- ignoremods=["os", "posixpath", "stat"],
- trace=False, count=True)
+ tracer = TestTrace(options, trace=False, count=True)
tracer.start()
else:
tracer = None
More information about the Zope3-Checkins
mailing list