summaryrefslogtreecommitdiff
path: root/testlib.py
diff options
context:
space:
mode:
authorJulien Cristau <julien.cristau@logilab.fr>2013-07-22 08:51:35 +0200
committerJulien Cristau <julien.cristau@logilab.fr>2013-07-22 08:51:35 +0200
commitc7a5df7f9cb4ad06174655185b319d91ea4f84f2 (patch)
tree7ca127025f383987dd1ba64b5c8496326bf172e2 /testlib.py
parent84ba539413f84d320a4a59db95d38361b054383e (diff)
downloadlogilab-common-c7a5df7f9cb4ad06174655185b319d91ea4f84f2.tar.gz
testlib: fix for python 3.3
unittest.TestCase no longer has a assertSameElements method. Use assertCountEqual instead of assertSameElements/assertItemsEqual. Closes #144526
Diffstat (limited to 'testlib.py')
-rw-r--r--testlib.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/testlib.py b/testlib.py
index 0517032..27326b8 100644
--- a/testlib.py
+++ b/testlib.py
@@ -721,7 +721,7 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
base = ''
self.fail(base + '\n'.join(msgs))
- @deprecated('Please use assertItemsEqual instead.')
+ @deprecated('Please use assertCountEqual instead.')
def assertUnorderedIterableEquals(self, got, expected, msg=None):
"""compares two iterable and shows difference between both
@@ -1183,10 +1183,13 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
assertRaises = failUnlessRaises
- if not hasattr(unittest.TestCase, 'assertItemsEqual'):
- # python 3.2 has deprecated assertSameElements and is missing
- # assertItemsEqual
- assertItemsEqual = unittest.TestCase.assertSameElements
+ if sys.version_info >= (3,2):
+ assertItemsEqual = unittest.TestCase.assertCountEqual
+ else:
+ assertCountEqual = unittest.TestCase.assertItemsEqual
+
+TestCase.assertItemsEqual = deprecated('assertItemsEqual is deprecated, use assertCountEqual')(
+ TestCase.assertItemsEqual)
import doctest