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/support | |
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/support')
-rw-r--r-- | Lib/test/support/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index c82037e..d34f2ef 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -113,7 +113,7 @@ __all__ = [ "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", "run_with_tz", "PGO", "missing_compiler_executable", "fd_count", - "ALWAYS_EQ", "LARGEST", "SMALLEST" + "ALWAYS_EQ", "NEVER_EQ", "LARGEST", "SMALLEST" ] class Error(Exception): @@ -3115,6 +3115,17 @@ class _ALWAYS_EQ: ALWAYS_EQ = _ALWAYS_EQ() +class _NEVER_EQ: + """ + Object that is not equal to anything. + """ + def __eq__(self, other): + return False + def __ne__(self, other): + return True + +NEVER_EQ = _NEVER_EQ() + @functools.total_ordering class _LARGEST: """ |