Made a test compatible with Python 2 and 3.
This commit is contained in:
parent
11284a63d4
commit
d98cc41a84
|
@ -663,10 +663,12 @@ def add_metaclass(metaclass):
|
||||||
### Additional customizations for Django ###
|
### Additional customizations for Django ###
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
|
_assertCountEqual = "assertCountEqual"
|
||||||
_assertRaisesRegex = "assertRaisesRegex"
|
_assertRaisesRegex = "assertRaisesRegex"
|
||||||
_assertRegex = "assertRegex"
|
_assertRegex = "assertRegex"
|
||||||
memoryview = memoryview
|
memoryview = memoryview
|
||||||
else:
|
else:
|
||||||
|
_assertCountEqual = "assertItemsEqual"
|
||||||
_assertRaisesRegex = "assertRaisesRegexp"
|
_assertRaisesRegex = "assertRaisesRegexp"
|
||||||
_assertRegex = "assertRegexpMatches"
|
_assertRegex = "assertRegexpMatches"
|
||||||
# memoryview and buffer are not strictly equivalent, but should be fine for
|
# memoryview and buffer are not strictly equivalent, but should be fine for
|
||||||
|
@ -678,6 +680,10 @@ else:
|
||||||
memoryview = buffer
|
memoryview = buffer
|
||||||
|
|
||||||
|
|
||||||
|
def assertCountEqual(self, *args, **kwargs):
|
||||||
|
return getattr(self, _assertCountEqual)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def assertRaisesRegex(self, *args, **kwargs):
|
def assertRaisesRegex(self, *args, **kwargs):
|
||||||
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
|
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -681,7 +681,7 @@ class BackendTestCase(TestCase):
|
||||||
|
|
||||||
self.assertIsInstance(connection.queries, list)
|
self.assertIsInstance(connection.queries, list)
|
||||||
self.assertIsInstance(connection.queries[0], dict)
|
self.assertIsInstance(connection.queries[0], dict)
|
||||||
self.assertItemsEqual(connection.queries[0].keys(), ['sql', 'time'])
|
six.assertCountEqual(self, connection.queries[0].keys(), ['sql', 'time'])
|
||||||
|
|
||||||
reset_queries()
|
reset_queries()
|
||||||
self.assertEqual(0, len(connection.queries))
|
self.assertEqual(0, len(connection.queries))
|
||||||
|
|
Loading…
Reference in New Issue