[Zodb-checkins] SVN: ZODB/branches/test_repozo/src/ZODB/scripts/ redo code of revisions 105888, 105915 and 105919
Godefroid Chapelle
gotcha at bubblenet.be
Wed Dec 2 12:34:26 EST 2009
Log message for revision 106186:
redo code of revisions 105888, 105915 and 105919
Changed:
U ZODB/branches/test_repozo/src/ZODB/scripts/repozo.py
U ZODB/branches/test_repozo/src/ZODB/scripts/tests/test_repozo.py
-=-
Modified: ZODB/branches/test_repozo/src/ZODB/scripts/repozo.py
===================================================================
--- ZODB/branches/test_repozo/src/ZODB/scripts/repozo.py 2009-12-02 17:17:27 UTC (rev 106185)
+++ ZODB/branches/test_repozo/src/ZODB/scripts/repozo.py 2009-12-02 17:34:25 UTC (rev 106186)
@@ -65,7 +65,12 @@
import os
import sys
-import md5
+try:
+ # the hashlib package is available from Python 2.5
+ from hashlib import md5
+except ImportError:
+ # the md5 package is deprecated in Python 2.6
+ from md5 import new as md5
import gzip
import time
import errno
@@ -210,7 +215,7 @@
def checksum(fp, n):
# Checksum the first n bytes of the specified file
- sum = md5.new()
+ sum = md5()
def func(data):
sum.update(data)
dofile(func, fp, n)
@@ -221,7 +226,7 @@
# Copy bytes from file src, to file dst, starting at offset start, for n
# length of bytes. For robustness, we first write, flush and fsync
# to a temp file, then rename the temp file at the end.
- sum = md5.new()
+ sum = md5()
ifp = open(options.file, 'rb')
ifp.seek(start)
tempname = os.path.join(os.path.dirname(dst), 'tmp.tmp')
@@ -248,7 +253,7 @@
# Concatenate a bunch of files from the repository, output to `outfile' if
# given. Return the number of bytes written and the md5 checksum of the
# bytes.
- sum = md5.new()
+ sum = md5()
def func(data):
sum.update(data)
if ofp:
Modified: ZODB/branches/test_repozo/src/ZODB/scripts/tests/test_repozo.py
===================================================================
--- ZODB/branches/test_repozo/src/ZODB/scripts/tests/test_repozo.py 2009-12-02 17:17:27 UTC (rev 106185)
+++ ZODB/branches/test_repozo/src/ZODB/scripts/tests/test_repozo.py 2009-12-02 17:34:25 UTC (rev 106186)
@@ -73,9 +73,14 @@
self.close()
-# Do recovery to time 'when', and check that it's identical to correctpath.
-class RepozoTest(unittest.TestCase):
+class BasicRepozoTests(unittest.TestCase):
+ def test_importability(self):
+ from ZODB.scripts import repozo
+
+
+class RepozoTests(unittest.TestCase):
+
def setUp(self):
# compute directory names
self.basedir = os.path.dirname(tests_module.__file__)
@@ -140,6 +145,7 @@
self.assertRestored()
def assertRestored(self, correctpath='Data.fs', when=None):
+ # Do recovery to time 'when', and check that it's identical to correctpath.
if when is None:
extra = ''
else:
@@ -171,7 +177,8 @@
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(RepozoTest))
+ suite.addTest(unittest.makeSuite(BasicRepozoTests))
+ suite.addTest(unittest.makeSuite(RepozoTests))
return suite
More information about the Zodb-checkins
mailing list