]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove unused/redundant methods in cinder/test.py
authorZhongyue Luo <zhongyue.nah@intel.com>
Sat, 7 Sep 2013 02:42:17 +0000 (10:42 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Sat, 7 Sep 2013 02:43:27 +0000 (10:43 +0800)
The following methods are not used anywhere in Cinder
- assertDictListMatch()
- assertSubDictMatch()

The following methods are implemented in testtools
- assertIn()
- assertNotIn()

Change-Id: Iea96f7761c33ac774b5b4ae71e544aa007ba1bb2

cinder/test.py

index 9d58c7ee5500c9b54b6082a5acf2d3c43e6744bb..1f0f2908e9a114738591c0552c2e7b79a7e11a1c 100644 (file)
@@ -267,54 +267,3 @@ class TestCase(testtools.TestCase):
                                     'd1value': d1value,
                                     'd2value': d2value,
                                 })
-
-    def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001):
-        """Assert a list of dicts are equivalent."""
-        def raise_assertion(msg):
-            L1str = str(L1)
-            L2str = str(L2)
-            base_msg = ('List of dictionaries do not match: %(msg)s '
-                        'L1: %(L1str)s L2: %(L2str)s' %
-                        {'msg': msg, 'L1str': L1str, 'L2str': L2str})
-            raise AssertionError(base_msg)
-
-        L1count = len(L1)
-        L2count = len(L2)
-        if L1count != L2count:
-            raise_assertion('Length mismatch: len(L1)=%(L1count)d != '
-                            'len(L2)=%(L2count)d' %
-                            {'L1count': L1count, 'L2count': L2count})
-
-        for d1, d2 in zip(L1, L2):
-            self.assertDictMatch(d1, d2, approx_equal=approx_equal,
-                                 tolerance=tolerance)
-
-    def assertSubDictMatch(self, sub_dict, super_dict):
-        """Assert a sub_dict is subset of super_dict."""
-        self.assertTrue(set(sub_dict.keys()).issubset(set(super_dict.keys())))
-        for k, sub_value in sub_dict.items():
-            super_value = super_dict[k]
-            if isinstance(sub_value, dict):
-                self.assertSubDictMatch(sub_value, super_value)
-            elif 'DONTCARE' in (sub_value, super_value):
-                continue
-            else:
-                self.assertEqual(sub_value, super_value)
-
-    def assertIn(self, a, b, *args, **kwargs):
-        """Python < v2.7 compatibility.  Assert 'a' in 'b'"""
-        try:
-            f = super(TestCase, self).assertIn
-        except AttributeError:
-            self.assertTrue(a in b, *args, **kwargs)
-        else:
-            f(a, b, *args, **kwargs)
-
-    def assertNotIn(self, a, b, *args, **kwargs):
-        """Python < v2.7 compatibility.  Assert 'a' NOT in 'b'"""
-        try:
-            f = super(TestCase, self).assertNotIn
-        except AttributeError:
-            self.assertFalse(a in b, *args, **kwargs)
-        else:
-            f(a, b, *args, **kwargs)