summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-01-24 12:47:31 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-01-28 18:48:50 -0800
commitf0836ab7ea64017de66040324426f08b4cc05458 (patch)
tree655c71736c907ba67e37e991d258c54f8c909f55 /tests
parent3dfb8437fc9135465f2b66b2c420bf20899fcf10 (diff)
downloadpython-keystoneclient-f0836ab7ea64017de66040324426f08b4cc05458.tar.gz
Fix how python 2.6 doesn't have assertDictEqual
Change-Id: I2e3a3dcc173bb5eae0b3e19f1c0eadc496a17e73
Diffstat (limited to 'tests')
-rw-r--r--tests/test_auth_token_middleware.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_auth_token_middleware.py b/tests/test_auth_token_middleware.py
index 40fc401..5b0d172 100644
--- a/tests/test_auth_token_middleware.py
+++ b/tests/test_auth_token_middleware.py
@@ -18,6 +18,7 @@ import datetime
import iso8601
import os
import string
+import sys
import tempfile
import testtools
@@ -403,6 +404,33 @@ class BaseAuthTokenMiddlewareTest(testtools.TestCase):
self.response_headers = dict(headers)
+if tuple(sys.version_info)[0:2] < (2, 7):
+
+ # 2.6 doesn't have the assert dict equals so make sure that it exists
+ class AdjustedBaseAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest):
+ def assertIsInstance(self, obj, cls, msg=None):
+ """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
+ default message."""
+ if not isinstance(obj, cls):
+ standardMsg = '%s is not an instance of %r' % (obj, cls)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+ def assertDictEqual(self, d1, d2, msg=None):
+ # Simple version taken from 2.7
+ self.assertIsInstance(d1, dict,
+ 'First argument is not a dictionary')
+ self.assertIsInstance(d2, dict,
+ 'Second argument is not a dictionary')
+ if d1 != d2:
+ if msg:
+ self.fail(msg)
+ else:
+ standardMsg = '%r != %r' % (d1, d2)
+ self.fail(standardMsg)
+
+ BaseAuthTokenMiddlewareTest = AdjustedBaseAuthTokenMiddlewareTest
+
+
class StackResponseAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest):
"""Auth Token middleware test setup that allows the tests to define
a stack of responses to HTTP requests in the test and get those