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:
Serhiy Storchaka 2019-08-04 14:12:48 +03:00 committed by GitHub
parent 17e52649c0
commit 18b711c5a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 86 additions and 22 deletions

View file

@ -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