From dd9fb4c6eb17734d2381e6fc638c1a345979137d Mon Sep 17 00:00:00 2001 From: Heikki Toivonen <308110+heikkitoivonen@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:06:45 -0800 Subject: [PATCH 1/2] Add Counter comparison tests to enforce missing element semantics --- Lib/test/test_collections.py | 4 ++++ .../next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst | 1 + 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index fad639b20a1801..b1b2dd2ca5ca0d 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -2423,6 +2423,8 @@ def test_eq(self): def test_le(self): self.assertTrue(Counter(a=3, b=2, c=0) <= Counter('ababa')) + self.assertTrue(Counter() <= Counter(c=1)) + self.assertFalse(Counter() <= Counter(c=-1)) self.assertFalse(Counter(a=3, b=2) <= Counter('babab')) def test_lt(self): @@ -2431,6 +2433,8 @@ def test_lt(self): def test_ge(self): self.assertTrue(Counter(a=2, b=1, c=0) >= Counter('aab')) + self.assertTrue(Counter() >= Counter(c=-1)) + self.assertFalse(Counter() >= Counter(c=1)) self.assertFalse(Counter(a=3, b=2, c=0) >= Counter('aabd')) def test_gt(self): diff --git a/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst b/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst new file mode 100644 index 00000000000000..7237d49bac4b73 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst @@ -0,0 +1 @@ +Add ``collections.Counter`` comparison tests to enforce missing element semantics. From d21fc0d9c656278bdf00eda9cc1dae2c8b044233 Mon Sep 17 00:00:00 2001 From: Heikki Toivonen <308110+heikkitoivonen@users.noreply.github.com> Date: Fri, 9 Jan 2026 09:20:10 -0800 Subject: [PATCH 2/2] Tests do not need news entry --- .../next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst diff --git a/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst b/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst deleted file mode 100644 index 7237d49bac4b73..00000000000000 --- a/Misc/NEWS.d/next/Tests/2026-01-08-15-04-38.gh-issue-143586.jLL4wL.rst +++ /dev/null @@ -1 +0,0 @@ -Add ``collections.Counter`` comparison tests to enforce missing element semantics.