Commit 8cca8987 authored by Jim Fulton's avatar Jim Fulton

Reverted revisions 105888, 105915 and 105919. I would love to reapply

105888 when there is an adequate test.  This can be achived through a
pretty straightforward conversion of the existing manual repozo test
to an automated test.
parent 379daad5
...@@ -65,6 +65,7 @@ Options for -R/--recover: ...@@ -65,6 +65,7 @@ Options for -R/--recover:
import os import os
import sys import sys
import md5
import gzip import gzip
import time import time
import errno import errno
...@@ -81,12 +82,6 @@ COMMASPACE = ', ' ...@@ -81,12 +82,6 @@ COMMASPACE = ', '
READCHUNK = 16 * 1024 READCHUNK = 16 * 1024
VERBOSE = False VERBOSE = False
if sys.version_info[1]>4:
# the hashlib package is available from Python 2.5
from hashlib import md5
else:
# the md5 package is deprecated in Python 2.6
from md5 import new as md5
def usage(code, msg=''): def usage(code, msg=''):
outfp = sys.stderr outfp = sys.stderr
...@@ -215,7 +210,7 @@ def dofile(func, fp, n=None): ...@@ -215,7 +210,7 @@ def dofile(func, fp, n=None):
def checksum(fp, n): def checksum(fp, n):
# Checksum the first n bytes of the specified file # Checksum the first n bytes of the specified file
sum = md5() sum = md5.new()
def func(data): def func(data):
sum.update(data) sum.update(data)
dofile(func, fp, n) dofile(func, fp, n)
...@@ -226,7 +221,7 @@ def copyfile(options, dst, start, n): ...@@ -226,7 +221,7 @@ def copyfile(options, dst, start, n):
# Copy bytes from file src, to file dst, starting at offset start, for n # 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 # length of bytes. For robustness, we first write, flush and fsync
# to a temp file, then rename the temp file at the end. # to a temp file, then rename the temp file at the end.
sum = md5() sum = md5.new()
ifp = open(options.file, 'rb') ifp = open(options.file, 'rb')
ifp.seek(start) ifp.seek(start)
tempname = os.path.join(os.path.dirname(dst), 'tmp.tmp') tempname = os.path.join(os.path.dirname(dst), 'tmp.tmp')
...@@ -253,7 +248,7 @@ def concat(files, ofp=None): ...@@ -253,7 +248,7 @@ def concat(files, ofp=None):
# Concatenate a bunch of files from the repository, output to `outfile' if # 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 # given. Return the number of bytes written and the md5 checksum of the
# bytes. # bytes.
sum = md5() sum = md5.new()
def func(data): def func(data):
sum.update(data) sum.update(data)
if ofp: if ofp:
......
...@@ -26,14 +26,8 @@ checker = renormalizing.RENormalizing([ ...@@ -26,14 +26,8 @@ checker = renormalizing.RENormalizing([
(re.compile('hash=[0-9a-f]{40}'), (re.compile('hash=[0-9a-f]{40}'),
'hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3')]) 'hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3')])
class RepozoTests(unittest.TestCase):
def test_importability(self):
from ZODB.scripts import repozo
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(RepozoTests),
doctest.DocFileSuite( doctest.DocFileSuite(
'referrers.txt', 'fstail.txt', 'referrers.txt', 'fstail.txt',
setUp=ZODB.tests.util.setUp, tearDown=ZODB.tests.util.tearDown, setUp=ZODB.tests.util.setUp, tearDown=ZODB.tests.util.tearDown,
......
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