Commit 24b1f8a9 authored by Jim Fulton's avatar Jim Fulton

Fixed numerous windows issues

parent 1c2e2768
......@@ -298,7 +298,7 @@ class FilesystemHelper:
# want to perform blob storage differently.
def __init__(self, base_dir, layout_name='automatic'):
self.base_dir = os.path.normpath(base_dir) + '/'
self.base_dir = os.path.normpath(base_dir) + os.path.sep
self.temp_dir = os.path.join(base_dir, 'tmp')
if layout_name == 'automatic':
......@@ -488,8 +488,8 @@ class BushyLayout(object):
"""
blob_path_pattern = r'^' + (r'0x[0-9a-f]{1,2}/*'*8) + r'$'
blob_path_pattern = re.compile(blob_path_pattern)
blob_path_pattern = re.compile(
r'(0x[0-9a-f]{1,2}\%s){7,7}0x[0-9a-f]{1,2}$' % os.path.sep)
def oid_to_path(self, oid):
directories = []
......@@ -497,12 +497,12 @@ class BushyLayout(object):
# first
for byte in str(oid):
directories.append('0x%s' % binascii.hexlify(byte))
return '/'.join(directories)
return os.path.sep.join(directories)
def path_to_oid(self, path):
if self.blob_path_pattern.match(path) is None:
raise ValueError("Not a valid OID path: `%s`" % path)
path = path.split('/')
path = path.split(os.path.sep)
# Each path segment stores a byte in hex representation. Turn it into
# an int and then get the character for our byte string.
oid = ''.join(binascii.unhexlify(byte[2:]) for byte in path)
......
......@@ -146,7 +146,7 @@ revision as well as the entire directory:
Clean up our blob directory and database:
>>> shutil.rmtree(blob_dir)
>>> rmtree(blob_dir)
>>> base_storage.close()
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+".index")
......@@ -273,4 +273,4 @@ knowledge that the underlying storage's pack method is also called:
Clean up our blob directory:
>>> shutil.rmtree(blob_dir)
>>> rmtree(blob_dir)
......@@ -381,6 +381,5 @@ We don't need the storage directory and databases anymore::
>>> tm1.abort()
>>> tm2.abort()
>>> database.close()
>>> import shutil
>>> shutil.rmtree(blob_dir)
>>> shutil.rmtree(blob_dir2)
>>> rmtree(blob_dir)
>>> rmtree(blob_dir2)
......@@ -12,7 +12,7 @@
#
##############################################################################
import base64, os, re, shutil, tempfile, unittest
import base64, os, re, shutil, stat, sys, tempfile, unittest
import time
from zope.testing import doctest, renormalizing
import ZODB.tests.util
......@@ -473,6 +473,11 @@ def secure_blob_directory():
"""
# On windows, we can't create secure blob directories, at least not
# with APIs in the standard library, so there's no point in testing
# this.
if sys.platform == 'win32':
del secure_blob_directory
def loadblob_tmpstore():
"""
......@@ -520,13 +525,26 @@ def loadblob_tmpstore():
>>> database.close()
>>> import shutil
>>> shutil.rmtree(blob_dir)
>>> rmtree(blob_dir)
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+".index")
>>> os.unlink(storagefile+".tmp")
"""
def setUp(test):
ZODB.tests.util.setUp(test)
def rmtree(path):
for path, dirs, files in os.walk(path, False):
for fname in files:
fname = os.path.join(path, fname)
os.chmod(fname, stat.S_IWUSR)
os.remove(fname)
for dname in dirs:
dname = os.path.join(path, dname)
os.rmdir(dname)
test.globs['rmtree'] = rmtree
def test_suite():
suite = unittest.TestSuite()
......@@ -536,22 +554,26 @@ def test_suite():
"blob_packing.txt", "blob_importexport.txt", "blob_consume.txt",
"blob_tempdir.txt",
optionflags=doctest.ELLIPSIS,
setUp=ZODB.tests.util.setUp,
setUp=setUp,
tearDown=ZODB.tests.util.tearDown,
))
suite.addTest(doctest.DocFileSuite(
"blob_layout.txt",
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
setUp=ZODB.tests.util.setUp,
setUp=setUp,
tearDown=ZODB.tests.util.tearDown,
checker = renormalizing.RENormalizing([
(re.compile(r'[%(sep)s]' % dict(sep=os.path.sep)), '/'),
(re.compile(r'\%(sep)s' % dict(sep=os.path.sep)), '/'),
(re.compile(r'\S+/((old|bushy|lawn)/\S+/foo[23456]?)'), r'\1'),
]),
))
suite.addTest(doctest.DocTestSuite(
setUp=ZODB.tests.util.setUp,
setUp=setUp,
tearDown=ZODB.tests.util.tearDown,
checker = renormalizing.RENormalizing([
(re.compile(r'\%(sep)s\%(sep)s' % dict(sep=os.path.sep)), '/'),
(re.compile(r'\%(sep)s' % dict(sep=os.path.sep)), '/'),
]),
))
suite.addTest(unittest.makeSuite(BlobUndoTests))
......
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