Commit 00a73cb0 authored by Jim Fulton's avatar Jim Fulton

Need at atexit handler to clean out layer directories, since the test

runner doesn't call layer teardown when a layer is run as a
subprocess.  This seems insane, ...
parent bc6e4a82
...@@ -18,6 +18,7 @@ $Id$ ...@@ -18,6 +18,7 @@ $Id$
from ZODB.MappingStorage import DB from ZODB.MappingStorage import DB
import atexit
import os import os
import tempfile import tempfile
import time import time
...@@ -74,12 +75,19 @@ class MininalTestLayer: ...@@ -74,12 +75,19 @@ class MininalTestLayer:
self.tmp = tempfile.mkdtemp(self.__name__, dir=os.getcwd()) self.tmp = tempfile.mkdtemp(self.__name__, dir=os.getcwd())
os.chdir(self.tmp) os.chdir(self.tmp)
# sigh. tearDown isn't called when a layer is run in a sub-process.
atexit.register(clean, self.tmp)
def tearDown(self): def tearDown(self):
os.chdir(self.here) os.chdir(self.here)
zope.testing.setupstack.rmtree(self.tmp) zope.testing.setupstack.rmtree(self.tmp)
testSetUp = testTearDown = lambda self: None testSetUp = testTearDown = lambda self: None
def clean(tmp):
if os.path.isdir(tmp):
zope.testing.setupstack.rmtree(tmp)
class AAAA_Test_Runner_Hack(unittest.TestCase): class AAAA_Test_Runner_Hack(unittest.TestCase):
"""Hack to work around a bug in the test runner. """Hack to work around a bug in the test runner.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment