diff --git a/Lib/slapdtest.py b/Lib/slapdtest.py index 2580ef3..1aba887 100644 --- a/Lib/slapdtest.py +++ b/Lib/slapdtest.py @@ -12,6 +12,7 @@ import time import subprocess import logging +import atexit from logging.handlers import SysLogHandler import unittest @@ -151,6 +152,9 @@ def _cleanup_rundir(self): """ Recursively delete whole directory specified by `path' """ + # cleanup_rundir() is called in atexit handler. Until Python 3.4, + # the rest of the world is already destroyed. + import os, os.path if not os.path.exists(self.testrundir): return self._log.debug('clean-up %s', self.testrundir) @@ -278,6 +282,7 @@ def start(self): if self._proc is None: # prepare directory structure + atexit.register(self.stop) self._cleanup_rundir() self.setup_rundir() self._write_config()