diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-04 09:38:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-04 09:38:46 (GMT) |
commit | 17e52649c0e7e9389f1cc2444a53f059e24e6bca (patch) | |
tree | 2cfdcdaefd375aaf93ef6973f507ffb768ee5472 /Lib/test/support | |
parent | 5c72badd06a962fe0018ceb9916f3ae66314ea8e (diff) | |
download | cpython-17e52649c0e7e9389f1cc2444a53f059e24e6bca.zip cpython-17e52649c0e7e9389f1cc2444a53f059e24e6bca.tar.gz cpython-17e52649c0e7e9389f1cc2444a53f059e24e6bca.tar.bz2 |
bpo-37685: Fixed comparisons of datetime.timedelta and datetime.timezone. (GH-14996)
There was a discrepancy between the Python and C implementations.
Add singletons ALWAYS_EQ, LARGEST and SMALLEST in test.support
to test mixed type comparison.
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index dbbbdb0..c82037e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -113,6 +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" ] class Error(Exception): @@ -3103,6 +3104,41 @@ class FakePath: return self.path +class _ALWAYS_EQ: + """ + Object that is equal to anything. + """ + def __eq__(self, other): + return True + def __ne__(self, other): + return False + +ALWAYS_EQ = _ALWAYS_EQ() + +@functools.total_ordering +class _LARGEST: + """ + Object that is greater than anything (except itself). + """ + def __eq__(self, other): + return isinstance(other, _LARGEST) + def __lt__(self, other): + return False + +LARGEST = _LARGEST() + +@functools.total_ordering +class _SMALLEST: + """ + Object that is less than anything (except itself). + """ + def __eq__(self, other): + return isinstance(other, _SMALLEST) + def __gt__(self, other): + return False + +SMALLEST = _SMALLEST() + def maybe_get_event_loop_policy(): """Return the global event loop policy if one is set, else return None.""" return asyncio.events._event_loop_policy |