Commit e454ce4d authored by Jason Madden's avatar Jason Madden

Fix ResourceWarnings seen during testing, and a testrunner orphaned thread warning.

Fixes #266
parent cf15ac88
......@@ -131,6 +131,7 @@ Demo storages are configured using the ``demostorage`` section::
'base.fs'
>>> storage.changes.getName()
'Changes'
>>> storage.close()
``demostorage`` sections can contain up to 2 storage subsections,
named ``base`` and ``changes``, specifying the demo storage's base and
......
......@@ -667,9 +667,11 @@ def do_recover(options):
repofiles = find_files(options)
if not repofiles:
if options.date:
raise NoFiles('No files in repository before %s', options.date)
raise NoFiles('No files in repository before %s' % (options.date,))
else:
raise NoFiles('No files in repository')
files_to_close = ()
if options.output is None:
log('Recovering file to stdout')
outfp = sys.stdout
......@@ -682,6 +684,9 @@ def do_recover(options):
log('Recovering file to %s', options.output)
temporary_output_file = options.output + '.part'
outfp = open(temporary_output_file, 'wb')
files_to_close += (outfp,)
try:
if options.withverify:
datfile = os.path.splitext(repofiles[0])[0] + '.dat'
with open(datfile) as fp:
......@@ -724,9 +729,11 @@ def do_recover(options):
shutil.copyfile(source_index, target_index)
else:
log('No index file to restore: %s', source_index)
finally:
for f in files_to_close:
f.close()
if outfp != sys.stdout:
outfp.close()
if options.output is not None:
try:
os.rename(temporary_output_file, options.output)
except OSError:
......
......@@ -37,6 +37,9 @@ class ShutdownTest(ZODB.tests.util.TestCase):
'ZODBTests.fs', create=1)
self._db = ZODB.DB(self._storage)
def tearDown(self):
ZODB.tests.util.TestCase.tearDown(self)
def check_shutdown(self):
client_thread = ZODBClientThread(self._db, self)
client_thread.start()
......@@ -47,8 +50,8 @@ class ShutdownTest(ZODB.tests.util.TestCase):
# have different contents.
self._db.close()
def tearDown(self):
ZODB.tests.util.TestCase.tearDown(self)
# Be sure not to 'leak' the running thread.
client_thread.join()
def test_suite():
......
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