aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-29 21:12:12 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-29 21:12:12 -0500
commitb1540a08131173ace920f2d3d0829e54b8f26283 (patch)
treedf536ee64a1c89ec5e5b38d0e9c27bcbbcf51303 /libbe/storage/base.py
parentd595aba006a39a2d75067fb7fc82956538e7e16d (diff)
downloadbugseverywhere-b1540a08131173ace920f2d3d0829e54b8f26283.tar.gz
Fixed make_*_testcase_subclasses() to avoid duplication.
Also removed final check for 'parent' existence in Storage_add_remove_TestCase.test_remove_nonrooted() because some VCSs (e.g. Git) don't keep track of blank directories.
Diffstat (limited to 'libbe/storage/base.py')
-rw-r--r--libbe/storage/base.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/libbe/storage/base.py b/libbe/storage/base.py
index d16c30b..ffde475 100644
--- a/libbe/storage/base.py
+++ b/libbe/storage/base.py
@@ -501,7 +501,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], directory=False)
+ self.s.add(ids[-1], directory=(i % 2 == 0))
s = sorted(self.s.children())
self.failUnless(s == ids, '\n %s\n !=\n %s' % (s, ids))
@@ -513,7 +513,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], 'parent', directory=True)
+ self.s.add(ids[-1], 'parent', directory=(i % 2 == 0))
s = sorted(self.s.children('parent'))
self.failUnless(s == ids, '\n %s\n !=\n %s' % (s, ids))
s = self.s.children()
@@ -527,7 +527,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append('parent/%s' % str(i))
- self.s.add(ids[-1], 'parent', directory=True)
+ self.s.add(ids[-1], 'parent', directory=(i % 2 == 0))
s = sorted(self.s.children('parent'))
self.failUnless(s == ids, '\n %s\n !=\n %s' % (s, ids))
@@ -560,7 +560,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], directory=True)
+ self.s.add(ids[-1], directory=(i % 2 == 0))
for i in range(10):
self.s.remove(ids.pop())
s = sorted(self.s.children())
@@ -574,13 +574,14 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], 'parent', directory=False)
+ self.s.add(ids[-1], 'parent', directory=False)#(i % 2 == 0))
for i in range(10):
self.s.remove(ids.pop())
s = sorted(self.s.children('parent'))
self.failUnless(s == ids, '\n %s\n !=\n %s' % (s, ids))
- s = self.s.children()
- self.failUnless(s == ['parent'], s)
+ if len(s) > 0:
+ s = self.s.children()
+ self.failUnless(s == ['parent'], s)
def test_remove_directory_not_empty(self):
"""
@@ -590,7 +591,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], 'parent', directory=True)
+ self.s.add(ids[-1], 'parent', directory=(i % 2 == 0))
self.s.remove(ids.pop()) # empty directory removal succeeds
try:
self.s.remove('parent') # empty directory removal succeeds
@@ -610,7 +611,7 @@ if TESTING == True:
ids.append(str(i))
self.s.add(ids[-1], 'parent', directory=True)
for j in range(10): # add some grandkids
- self.s.add(str(20*(i+1)+j), ids[-1], directory=False)
+ self.s.add(str(20*(i+1)+j), ids[-1], directory=(i%2 == 0))
self.s.recursive_remove('parent')
s = sorted(self.s.children())
self.failUnless(s == [], s)
@@ -726,7 +727,7 @@ if TESTING == True:
ids = []
for i in range(10):
ids.append(str(i))
- self.s.add(ids[-1], 'parent', directory=False)
+ self.s.add(ids[-1], 'parent', directory=(i % 2 == 0))
self.s.disconnect()
self.s.connect()
s = sorted(self.s.children('parent'))
@@ -842,7 +843,7 @@ if TESTING == True:
children = []
for i in range(10):
new_child = str(i)
- self.s.add(new_child, 'parent', directory=False)
+ self.s.add(new_child, 'parent', directory=(i % 2 == 0))
self.s.set(new_child, self.val)
revs.append(self.s.commit('%s: %d' % (self.commit_msg, i),
self.commit_body))
@@ -861,7 +862,7 @@ if TESTING == True:
c for c in (
ob for ob in globals().values() if isinstance(ob, type))
if issubclass(c, StorageTestCase) \
- and not issubclass(c, VersionedStorageTestCase)]
+ and c.Class == Storage]
for base_class in storage_testcase_classes:
testcase_class_name = storage_class.__name__ + base_class.__name__
@@ -877,7 +878,8 @@ if TESTING == True:
storage_testcase_classes = [
c for c in (
ob for ob in globals().values() if isinstance(ob, type))
- if issubclass(c, StorageTestCase)]
+ if issubclass(c, StorageTestCase) \
+ and c.Class == Storage]
for base_class in storage_testcase_classes:
testcase_class_name = storage_class.__name__ + base_class.__name__