[Python-checkins] [3.11] Add tests for empty range equality (GH-103751) (#103760)

terryjreedy webhook-mailer at python.org
Mon Apr 24 11:09:54 EDT 2023


https://github.com/python/cpython/commit/25406e5a3576645e89450ed78c71058b53f0c65a
commit: 25406e5a3576645e89450ed78c71058b53f0c65a
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: terryjreedy <tjreedy at udel.edu>
date: 2023-04-24T11:09:46-04:00
summary:

[3.11] Add tests for empty range equality (GH-103751) (#103760)

(cherry picked from commit dca27a69a8261353f7f986eb8f808f0d487ac4b7)

Co-authored-by: Kirill <80244920+Eclips4 at users.noreply.github.com>

files:
M Lib/test/test_range.py

diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index 851ad5b7c2f4..83c830a10047 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -648,6 +648,11 @@ def test_comparison(self):
                          hash(range(2**200, 2**201, 2**100)))
         self.assertNotEqual(range(2**200, 2**201, 2**100),
                             range(2**200, 2**201 + 1, 2**100))
+        # Empty ranges
+        self.assertEqual(range(32, 16), range(0))
+        self.assertEqual(hash(range(32, 16)), hash(range(0)))
+        self.assertEqual(range(2, 1, 3), range(0))
+        self.assertEqual(hash(range(2, 1, 3)), hash(range(0)))
 
         # Order comparisons are not implemented for ranges.
         with self.assertRaises(TypeError):



More information about the Python-checkins mailing list