From: Zhongyue Luo Date: Sat, 7 Sep 2013 02:42:17 +0000 (+0800) Subject: Remove unused/redundant methods in cinder/test.py X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8bb034cedce78203b60342a825fb5935554ead2f;p=openstack-build%2Fcinder-build.git Remove unused/redundant methods in cinder/test.py The following methods are not used anywhere in Cinder - assertDictListMatch() - assertSubDictMatch() The following methods are implemented in testtools - assertIn() - assertNotIn() Change-Id: Iea96f7761c33ac774b5b4ae71e544aa007ba1bb2 --- diff --git a/cinder/test.py b/cinder/test.py index 9d58c7ee5..1f0f2908e 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -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)