[Zope3-checkins]
SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/
Moved garbage collection debug setup to its own feature.
Christian Theune
ct at gocept.com
Sun May 4 08:57:41 EDT 2008
Log message for revision 86358:
Moved garbage collection debug setup to its own feature.
Changed:
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/garbagecollection.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/garbagecollection.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/garbagecollection.py 2008-05-04 12:56:06 UTC (rev 86357)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/garbagecollection.py 2008-05-04 12:57:40 UTC (rev 86358)
@@ -50,3 +50,26 @@
def global_teardown(self):
gc.set_threshold(*self.old_threshold)
+
+
+class Debug(zope.testing.testrunner.feature.Feature):
+ """Manages garbage collection debug flags."""
+
+ def __init__(self, runner):
+ super(Debug, self).__init__(runner)
+ self.flags = self.runner.options.gc_option
+ self.active = bool(self.flags)
+
+ if not self.active:
+ return
+
+ def global_setup(self):
+ # Set garbage collection debug flags
+ self.old_flags = gc.get_debug()
+ new_flags = 0
+ for op in self.flags:
+ new_flags |= getattr(gc, op)
+ gc.set_debug(new_flags)
+
+ def global_teardown(self):
+ gc.set_debug(self.old_flags)
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 12:56:06 UTC (rev 86357)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py 2008-05-04 12:57:40 UTC (rev 86358)
@@ -170,18 +170,13 @@
self.features.append(zope.testing.testrunner.profiling.Profiling(self))
self.features.append(zope.testing.testrunner.timing.Timing(self))
self.features.append(zope.testing.testrunner.garbagecollection.Threshold(self))
+ self.features.append(zope.testing.testrunner.garbagecollection.Debug(self))
# Remove all features that aren't activated
self.features = [f for f in self.features if f.active]
def setup_features(self):
- # 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)
+ pass
def find_tests(self):
global _layer_name_cache
@@ -290,8 +285,7 @@
self.failed = bool(self.import_errors or self.failures or self.errors)
def shutdown_features(self):
- if self.options.gc_option:
- gc.set_debug(self.old_flags)
+ pass
def report(self):
if self.options.resume_layer:
More information about the Zope3-Checkins
mailing list