[Zope3-checkins]
SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/
Move garbage collection to the feature setup phase.
Christian Theune
ct at gocept.com
Sun May 4 05:04:38 EDT 2008
Log message for revision 86319:
Move garbage collection to the feature setup phase.
Changed:
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/testrunner-gc.txt
-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py 2008-05-04 08:56:30 UTC (rev 86318)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py 2008-05-04 09:04:38 UTC (rev 86319)
@@ -175,6 +175,30 @@
self.late_initializers.append(self.profiler.enable)
self.early_shutdown.append(self.profiler.disable)
+ # Setup garbage collection threshold
+ self.old_threshold = gc.get_threshold()
+ if self.options.gc:
+ if len(self.options.gc) > 3:
+ output.error("Too many --gc options")
+ sys.exit(1)
+ if self.options.gc[0]:
+ self.options.output.info(
+ "Cyclic garbage collection threshold set to: %s" %
+ repr(tuple(self.options.gc)))
+ else:
+ self.options.output.info(
+ "Cyclic garbage collection is disabled.")
+
+ gc.set_threshold(*self.options.gc)
+
+ # Set garbage collection debug flags
+ self.old_flags = gc.get_debug()
+ if self.options.gc_option:
+ new_flags = 0
+ for op in self.options.gc_option:
+ new_flags |= getattr(gc, op)
+ gc.set_debug(new_flags)
+
def find_tests(self):
pass
@@ -205,26 +229,6 @@
msg = "Running tests at level %d" % self.options.at_level
output.info(msg)
- old_threshold = gc.get_threshold()
- if self.options.gc:
- if len(self.options.gc) > 3:
- output.error("Too many --gc options")
- sys.exit(1)
- if self.options.gc[0]:
- output.info("Cyclic garbage collection threshold set to: %s" %
- repr(tuple(self.options.gc)))
- else:
- output.info("Cyclic garbage collection is disabled.")
-
- gc.set_threshold(*self.options.gc)
-
- old_flags = gc.get_debug()
- if self.options.gc_option:
- new_flags = 0
- for op in self.options.gc_option:
- new_flags |= getattr(gc, op)
- gc.set_debug(new_flags)
-
self.old_reporting_flags = doctest.set_unittest_reportflags(0)
reporting_flags = 0
if self.options.ndiff:
@@ -247,7 +251,6 @@
else:
doctest.set_unittest_reportflags(self.old_reporting_flags)
-
# Add directories to the path
for path in self.options.path:
if path not in sys.path:
@@ -356,10 +359,10 @@
doctest.set_unittest_reportflags(self.old_reporting_flags)
if self.options.gc_option:
- gc.set_debug(old_flags)
+ gc.set_debug(self.old_flags)
if self.options.gc:
- gc.set_threshold(*old_threshold)
+ gc.set_threshold(*self.old_threshold)
self.failed = bool(import_errors or failures or errors)
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/testrunner-gc.txt
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/testrunner-gc.txt 2008-05-04 08:56:30 UTC (rev 86318)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/testrunner-gc.txt 2008-05-04 09:04:38 UTC (rev 86319)
@@ -18,8 +18,8 @@
>>> sys.argv = 'test --tests-pattern ^gc0$ --gc 0 -vv'.split()
>>> _ = testrunner.run(defaults)
+ Cyclic garbage collection is disabled.
Running tests at level 1
- Cyclic garbage collection is disabled.
Running unit tests:
Running:
make_sure_gc_is_disabled (gc0)
@@ -31,8 +31,8 @@
>>> sys.argv = 'test --tests-pattern ^gc1$ --gc 1 -vv'.split()
>>> _ = testrunner.run(defaults)
+ Cyclic garbage collection threshold set to: (1,)
Running tests at level 1
- Cyclic garbage collection threshold set to: (1,)
Running unit tests:
Running:
make_sure_gc_threshold_is_one (gc1)
@@ -45,8 +45,8 @@
>>> sys.argv = ('test --tests-pattern ^gcset$ --gc 701 --gc 11 --gc 9 -vv'
... .split())
>>> _ = testrunner.run(defaults)
+ Cyclic garbage collection threshold set to: (701, 11, 9)
Running tests at level 1
- Cyclic garbage collection threshold set to: (701, 11, 9)
Running unit tests:
Running:
make_sure_gc_threshold_is_701_11_9 (gcset)
More information about the Zope3-Checkins
mailing list