mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
#7092: silence some more py3k warnings.
This commit is contained in:
parent
8b3f1ce591
commit
d80b4bfd0b
9 changed files with 84 additions and 56 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue