diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-04 11:12:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-04 11:12:48 (GMT) |
commit | 18b711c5a7f90d88fb74748f18fa8ef49d8486c7 (patch) | |
tree | d04ab59ccadbade80f8999c921dd3a19b62a9cc9 /Lib/test/list_tests.py | |
parent | 17e52649c0e7e9389f1cc2444a53f059e24e6bca (diff) | |
download | cpython-18b711c5a7f90d88fb74748f18fa8ef49d8486c7.zip cpython-18b711c5a7f90d88fb74748f18fa8ef49d8486c7.tar.gz cpython-18b711c5a7f90d88fb74748f18fa8ef49d8486c7.tar.bz2 |
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 ==.
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r-- | Lib/test/list_tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index 40316de..44bc2ae 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -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 |