summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_set.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-03-17 13:52:48 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-03-17 13:52:48 (GMT)
commitd80b4bfd0b291d543c682d7dac0841de0192a238 (patch)
tree3968f81c285078b86b95aedddc6246f4d901a542 /Lib/test/test_set.py
parent8b3f1ce5916c3ec5f426d45496b313d7be6ea3a1 (diff)
downloadcpython-d80b4bfd0b291d543c682d7dac0841de0192a238.zip
cpython-d80b4bfd0b291d543c682d7dac0841de0192a238.tar.gz
cpython-d80b4bfd0b291d543c682d7dac0841de0192a238.tar.bz2
#7092: silence some more py3k warnings.
Diffstat (limited to 'Lib/test/test_set.py')
-rw-r--r--Lib/test/test_set.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 808cf27..1548a65 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -1377,21 +1377,17 @@ class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
class TestCopying(unittest.TestCase):
def test_copy(self):
- dup = self.set.copy()
- dup_list = list(dup); dup_list.sort()
- set_list = list(self.set); set_list.sort()
- self.assertEqual(len(dup_list), len(set_list))
- for i in range(len(dup_list)):
- self.assertTrue(dup_list[i] is set_list[i])
+ dup = list(self.set.copy())
+ self.assertEqual(len(dup), len(self.set))
+ for el in self.set:
+ self.assertIn(el, dup)
+ pos = dup.index(el)
+ self.assertIs(el, dup.pop(pos))
+ self.assertFalse(dup)
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- ##print type(dup), repr(dup)
- dup_list = list(dup); dup_list.sort()
- set_list = list(self.set); set_list.sort()
- self.assertEqual(len(dup_list), len(set_list))
- for i in range(len(dup_list)):
- self.assertEqual(dup_list[i], set_list[i])
+ self.assertSetEqual(dup, self.set)
#------------------------------------------------------------------------------
@@ -1551,7 +1547,7 @@ class TestVariousIteratorArgs(unittest.TestCase):
for cons in (set, frozenset):
for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(sorted(cons(g(s))), sorted(g(s)))
+ self.assertSetEqual(cons(g(s)), set(g(s)))
self.assertRaises(TypeError, cons , X(s))
self.assertRaises(TypeError, cons , N(s))
self.assertRaises(ZeroDivisionError, cons , E(s))
@@ -1566,7 +1562,7 @@ class TestVariousIteratorArgs(unittest.TestCase):
if isinstance(expected, bool):
self.assertEqual(actual, expected)
else:
- self.assertEqual(sorted(actual), sorted(expected))
+ self.assertSetEqual(actual, expected)
self.assertRaises(TypeError, meth, X(s))
self.assertRaises(TypeError, meth, N(s))
self.assertRaises(ZeroDivisionError, meth, E(s))
@@ -1580,7 +1576,7 @@ class TestVariousIteratorArgs(unittest.TestCase):
t = s.copy()
getattr(s, methname)(list(g(data)))
getattr(t, methname)(g(data))
- self.assertEqual(sorted(s), sorted(t))
+ self.assertSetEqual(s, t)
self.assertRaises(TypeError, getattr(set('january'), methname), X(data))
self.assertRaises(TypeError, getattr(set('january'), methname), N(data))