Commit 10303c07 authored by Tres Seaver's avatar Tres Seaver

Moar resource leak patchage.

parent 166c5b76
...@@ -234,20 +234,19 @@ class FileStorageTests( ...@@ -234,20 +234,19 @@ class FileStorageTests(
self.open() self.open()
# Open .fs directly, and damage content. # Open .fs directly, and damage content.
f = open('FileStorageTests.fs', 'r+b') with open('FileStorageTests.fs', 'r+b') as f:
f.seek(0, 2) f.seek(0, 2)
pos2 = f.tell() - 8 pos2 = f.tell() - 8
f.seek(pos2) f.seek(pos2)
tlen2 = U64(f.read(8)) # length-8 of the last transaction tlen2 = U64(f.read(8)) # length-8 of the last transaction
pos1 = pos2 - tlen2 + 8 # skip over the tid at the start pos1 = pos2 - tlen2 + 8 # skip over the tid at the start
f.seek(pos1) f.seek(pos1)
tlen1 = U64(f.read(8)) # should be redundant length-8 tlen1 = U64(f.read(8)) # should be redundant length-8
self.assertEqual(tlen1, tlen2) # verify that it is redundant self.assertEqual(tlen1, tlen2) # verify that it is redundant
# Now damage the second copy. # Now damage the second copy.
f.seek(pos2) f.seek(pos2)
f.write(p64(tlen2 - 1)) f.write(p64(tlen2 - 1))
f.close()
# Try to pack. This used to yield # Try to pack. This used to yield
# NameError: global name 's' is not defined # NameError: global name 's' is not defined
......
...@@ -71,14 +71,13 @@ class ZODBTests(ZODB.tests.util.TestCase): ...@@ -71,14 +71,13 @@ class ZODBTests(ZODB.tests.util.TestCase):
assert len(ob) > 10, 'Insufficient test data' assert len(ob) > 10, 'Insufficient test data'
try: try:
import tempfile import tempfile
f = tempfile.TemporaryFile() with tempfile.TemporaryFile(prefix="DUP") as f:
ob._p_jar.exportFile(ob._p_oid, f) ob._p_jar.exportFile(ob._p_oid, f)
assert f.tell() > 0, 'Did not export correctly' assert f.tell() > 0, 'Did not export correctly'
f.seek(0) f.seek(0)
new_ob = ob._p_jar.importFile(f) new_ob = ob._p_jar.importFile(f)
self.assertEqual(new_ob, ob) self.assertEqual(new_ob, ob)
root['dup'] = new_ob root['dup'] = new_ob
f.close()
if abort_it: if abort_it:
transaction.abort() transaction.abort()
else: else:
......
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