testlib: fix for python 3.3

unittest.TestCase no longer has a assertSameElements method. Closes #144526

authorJulien Cristau <julien.cristau@logilab.fr>
changesete1a6f9f362b4
branchstable
phasedraft
hiddenyes
parent revision#5a8fb4b4a7f5 [modutils] fix python3.3 crash on file_from_modpath. Closes #137244
child revision<not specified>
files modified by this revision
testlib.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1371646363 -7200
# Wed Jun 19 14:52:43 2013 +0200
# Branch stable
# Node ID e1a6f9f362b437dc9fbbf273c69eb37b37550798
# Parent 5a8fb4b4a7f567b65b8f935282316be0b1f9018e
testlib: fix for python 3.3

unittest.TestCase no longer has a assertSameElements method.
Closes #144526

diff --git a/testlib.py b/testlib.py
@@ -1181,11 +1181,12 @@
1                  excName = str(excClass)
2              raise self.failureException("%s not raised" % excName)
3 
4      assertRaises = failUnlessRaises
5 
6 -    if not hasattr(unittest.TestCase, 'assertItemsEqual'):
7 +    if (hasattr(unittest.TestCase, 'assertSameElements') and
8 +        not hasattr(unittest.TestCase, 'assertItemsEqual')):
9          # python 3.2 has deprecated assertSameElements and is missing
10          # assertItemsEqual
11          assertItemsEqual = unittest.TestCase.assertSameElements
12 
13  import doctest