mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
bpo-37648: Fixed minor inconsistency in some __contains__. (GH-14904)
The collection's item is now always at the left and the needle is on the right of ==.
This commit is contained in:
parent
17e52649c0
commit
18b711c5a7
12 changed files with 86 additions and 22 deletions
|
@ -7,6 +7,7 @@ import os
|
|||
from functools import cmp_to_key
|
||||
|
||||
from test import support, seq_tests
|
||||
from test.support import ALWAYS_EQ, NEVER_EQ
|
||||
|
||||
|
||||
class CommonTest(seq_tests.CommonTest):
|
||||
|
@ -329,6 +330,20 @@ class CommonTest(seq_tests.CommonTest):
|
|||
|
||||
self.assertRaises(TypeError, a.remove)
|
||||
|
||||
a = self.type2test([1, 2])
|
||||
self.assertRaises(ValueError, a.remove, NEVER_EQ)
|
||||
self.assertEqual(a, [1, 2])
|
||||
a.remove(ALWAYS_EQ)
|
||||
self.assertEqual(a, [2])
|
||||
a = self.type2test([ALWAYS_EQ])
|
||||
a.remove(1)
|
||||
self.assertEqual(a, [])
|
||||
a = self.type2test([ALWAYS_EQ])
|
||||
a.remove(NEVER_EQ)
|
||||
self.assertEqual(a, [])
|
||||
a = self.type2test([NEVER_EQ])
|
||||
self.assertRaises(ValueError, a.remove, ALWAYS_EQ)
|
||||
|
||||
class BadExc(Exception):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue