Fixed make_*_testcase_subclasses() to avoid duplication.
authorW. Trevor King <wking@drexel.edu>
Wed, 30 Dec 2009 02:12:12 +0000 (21:12 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 30 Dec 2009 02:12:12 +0000 (21:12 -0500)
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.

libbe/storage/base.py
libbe/storage/vcs/base.py

index d16c30bc2c951b91e560f79bff65892ff92db55b..ffde475fb6b8099bd026c579363b467b1d9f4915 100644 (file)
@@ -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__
index 533ef4c4f661dd5aa8bc9c95380672eface265b5..6ece16d3009facca3cab2c3f864c702fb92f734a 100644 (file)
@@ -1085,7 +1085,8 @@ if libbe.TESTING == True:
             vcs_testcase_classes = [
                 c for c in (
                     ob for ob in globals().values() if isinstance(ob, type))
-                if issubclass(c, VCSTestCase)]
+                if issubclass(c, VCSTestCase) \
+                    and c.Class == VCS]
 
             for base_class in vcs_testcase_classes:
                 testcase_class_name = vcs_class.__name__ + base_class.__name__