Commit 4dcb6d14 authored by Jason Madden's avatar Jason Madden

Incorporate feedback and make the tests run under Python3. Notably, the Grand...

Incorporate feedback and make the tests run under Python3. Notably, the Grand Exception Unification in Python 3.3 means that IOError is a synonym for OSError in those versions, but not before; deal with this by catching both types and throwing OSError in the doctests (because that's how it prints). Fix #21. Fix #22.
parent 69d72b2d
......@@ -435,7 +435,7 @@ class FileStoragePacker(FileStorageFormatter):
self._copier = PackCopier(self._tfile, self.index, self.tindex)
ipos, opos = self.copyToPacktime()
except IOError:
except (OSError, IOError):
# most probably ran out of disk space or some other IO error
close_files_remove()
raise # don't succeed silently
......@@ -482,7 +482,7 @@ class FileStoragePacker(FileStorageFormatter):
self.blob_removed.close()
return pos
except IOError:
except (OSError, IOError):
# most probably ran out of disk space or some other IO error
close_files_remove()
if self.locked:
......
......@@ -195,7 +195,7 @@ Add some data
>>> fs = ZODB.FileStorage.FileStorage('data.fs')
>>> db = ZODB.DB(fs)
>>> conn = db.open()
>>> conn.root()[1] = u'foobar'
>>> conn.root()[1] = 'foobar'
>>> transaction.commit()
patch `copyToPacktime` to fail
......@@ -204,17 +204,17 @@ patch `copyToPacktime` to fail
>>> save_copyToPacktime = fspack.FileStoragePacker.copyToPacktime
>>> def failing_copyToPacktime(self):
... self._tfile.write('somejunkdata')
... raise IOError("No space left on device")
... self._tfile.write(b'somejunkdata')
... raise OSError("No space left on device")
>>> fspack.FileStoragePacker.copyToPacktime = failing_copyToPacktime
pack -- it still raises `IOError`
pack -- it still raises `OSError`
>>> db.pack(time.time()+1)
Traceback (most recent call last):
...
IOError: No space left on device
OSError: No space left on device
`data.fs.pack` must not exist
......@@ -233,7 +233,7 @@ check the data we added
>>> db = ZODB.DB(fs)
>>> conn = db.open()
>>> conn.root()[1]
u'foobar'
'foobar'
>>> db.close()
"""
......@@ -247,7 +247,7 @@ Add some data
>>> fs = ZODB.FileStorage.FileStorage('data.fs')
>>> db = ZODB.DB(fs)
>>> conn = db.open()
>>> conn.root()[1] = u'foobar'
>>> conn.root()[1] = 'foobar'
>>> transaction.commit()
patch `copyToPacktime` to add one more transaction
......@@ -258,7 +258,7 @@ patch `copyToPacktime` to add one more transaction
>>> def patched_copyToPacktime(self):
... res = save_copyToPacktime(self)
... conn2 = db.open()
... conn2.root()[2] = u'another bar'
... conn2.root()[2] = 'another bar'
... transaction.commit()
... return res
......@@ -269,17 +269,17 @@ patch `copyRest` to fail
>>> save_copyRest = fspack.FileStoragePacker.copyRest
>>> def failing_copyRest(self, ipos):
... self._tfile.write('somejunkdata')
... raise IOError("No space left on device")
... self._tfile.write(b'somejunkdata')
... raise OSError("No space left on device")
>>> fspack.FileStoragePacker.copyRest = failing_copyRest
pack -- it still raises `IOError`
pack -- it still raises `OSError`
>>> db.pack(time.time()+1)
Traceback (most recent call last):
...
IOError: No space left on device
OSError: No space left on device
`data.fs.pack` must not exist
......@@ -299,9 +299,9 @@ check the data we added
>>> db = ZODB.DB(fs)
>>> conn = db.open()
>>> conn.root()[1]
u'foobar'
'foobar'
>>> conn.root()[2]
u'another bar'
'another bar'
>>> db.close()
"""
......
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