From 8b27bcb3c5afb01fe006ba6f90969b08f63d5e75 Mon Sep 17 00:00:00 2001 From: sharktide Date: Tue, 4 Mar 2025 11:31:08 -0500 Subject: [PATCH 01/18] Update __init__.py --- Lib/tkinter/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 0baed8b569e40f..6b970ed5ff6216 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -4026,9 +4026,7 @@ def scan_dragto(self, x, y): scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y) - def search(self, pattern, index, stopindex=None, - forwards=None, backwards=None, exact=None, - regexp=None, nocase=None, count=None, elide=None): + def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None, elide=None, nolinestop=None, all=None, overlap=None, strictlimits=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" @@ -4040,12 +4038,18 @@ def search(self, pattern, index, stopindex=None, if nocase: args.append('-nocase') if elide: args.append('-elide') if count: args.append('-count'); args.append(count) + if nolinestop: args.append('-nolinestop') + if all: args.append('-all') + if overlap: args.append('-overlap') + if strictlimits: args.append('-strictlimits') if pattern and pattern[0] == '-': args.append('--') args.append(pattern) args.append(index) if stopindex: args.append(stopindex) return str(self.tk.call(tuple(args))) + + def see(self, index): """Scroll such that the character at INDEX is visible.""" self.tk.call(self._w, 'see', index) From 18d5005fc76139531734c003749ac1026bd78e1c Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 17:19:27 +0000 Subject: [PATCH 02/18] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst new file mode 100644 index 00000000000000..ba854217c39db4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -0,0 +1,13 @@ +================ +Type: Enhancement +Title: Add support for -nolinestop, -all, -overlap, and -strictlimits options to tkinter.Text.search +Issue: :gh:`130693` + +Detailed changes: +- Enhanced the `tkinter.Text.search` method by adding support for the following options: + - `-nolinestop`: Allows searching across lines without stopping. + - `-all`: Finds all matches instead of just the first match. + - `-overlap`: Finds matches that overlap with each other. + - `-strictlimits`: Ensures strict boundaries for the search. + +These improvements align the `tkinter.Text.search` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. From e2a76c217ac93ffd52dd815afac7f86c8ee79eda Mon Sep 17 00:00:00 2001 From: sharktide Date: Tue, 4 Mar 2025 12:23:07 -0500 Subject: [PATCH 03/18] Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst --- .../2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index ba854217c39db4..5cd419efb5d339 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1,13 +1,13 @@ ================ Type: Enhancement -Title: Add support for -nolinestop, -all, -overlap, and -strictlimits options to tkinter.Text.search +Title: Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` Issue: :gh:`130693` Detailed changes: -- Enhanced the `tkinter.Text.search` method by adding support for the following options: - - `-nolinestop`: Allows searching across lines without stopping. - - `-all`: Finds all matches instead of just the first match. - - `-overlap`: Finds matches that overlap with each other. - - `-strictlimits`: Ensures strict boundaries for the search. +- Enhanced the ``tkinter.Text.search`` method by adding support for the following options: + - ``-nolinestop``: Allows searching across lines without stopping. + - ``-all``: Finds all matches instead of just the first match. + - ``-overlap``: Finds matches that overlap with each other. + - ``-strictlimits``: Ensures strict boundaries for the search. -These improvements align the `tkinter.Text.search` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. +These improvements align the ``tkinter.Text.search`` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. From 753da3a8be395600dc73c3f61eab992ce6f8a979 Mon Sep 17 00:00:00 2001 From: sharktide Date: Wed, 5 Mar 2025 10:20:24 -0500 Subject: [PATCH 04/18] Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst --- .../2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index 5cd419efb5d339..9b2cdc7ecbe8cb 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -3,11 +3,5 @@ Type: Enhancement Title: Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` Issue: :gh:`130693` -Detailed changes: -- Enhanced the ``tkinter.Text.search`` method by adding support for the following options: - - ``-nolinestop``: Allows searching across lines without stopping. - - ``-all``: Finds all matches instead of just the first match. - - ``-overlap``: Finds matches that overlap with each other. - - ``-strictlimits``: Ensures strict boundaries for the search. -These improvements align the ``tkinter.Text.search`` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. +Added nolinestop, all, overlap, and strictlimits to tkinter.Text.search method From 1ca30c634e5d0f101b0d98ee0cf15380d160c142 Mon Sep 17 00:00:00 2001 From: sharktide Date: Wed, 5 Mar 2025 10:30:56 -0500 Subject: [PATCH 05/18] Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst --- .../Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index 9b2cdc7ecbe8cb..1b0639b499896e 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -3,5 +3,4 @@ Type: Enhancement Title: Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` Issue: :gh:`130693` - -Added nolinestop, all, overlap, and strictlimits to tkinter.Text.search method +Added nolinestop, all, overlap, and strictlimits to tkinter.Text.search method These improvements align the ``tkinter.Text.search`` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. From 6ce83e34fc250525799a6d683aaea46336d4a9a3 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Mon, 5 May 2025 11:47:53 -0400 Subject: [PATCH 06/18] pythongh-130693 Remove wordiness; only title left --- .../next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index 1b0639b499896e..d096f762ccdec6 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -2,5 +2,3 @@ Type: Enhancement Title: Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` Issue: :gh:`130693` - -Added nolinestop, all, overlap, and strictlimits to tkinter.Text.search method These improvements align the ``tkinter.Text.search`` method with the underlying Tcl/Tk library, providing more flexibility and functionality for users. From 39f58758286f2d0987425f39b357aa68bc6ebac0 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Fri, 30 May 2025 16:08:05 -0400 Subject: [PATCH 07/18] Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst --- .../Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index d096f762ccdec6..67e23996bcd455 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1,4 +1,2 @@ -================ -Type: Enhancement -Title: Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` -Issue: :gh:`130693` +Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` + From ba0c98ae0436eab18b5e23e7ef2d7f75fb297535 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 19:13:44 +0530 Subject: [PATCH 08/18] remove whitespace in Lib/tkinter/__init__.py Co-authored-by: Peter Bierma --- Lib/tkinter/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 1dca6d4d684e29..2b3d54b940177e 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -4060,8 +4060,6 @@ def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, if stopindex: args.append(stopindex) return str(self.tk.call(tuple(args))) - - def see(self, index): """Scroll such that the character at INDEX is visible.""" self.tk.call(self._w, 'see', index) From 754a12445ee72277e8da3977e8bb3a0c71129621 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 19:15:50 +0530 Subject: [PATCH 09/18] Revert formatting in Lib/tkinter/__init__.py --- Lib/tkinter/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 2b3d54b940177e..28961aa45d8711 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -4038,7 +4038,11 @@ def scan_dragto(self, x, y): scan_mark.""" self.tk.call(self._w, 'scan', 'dragto', x, y) - def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None, elide=None, nolinestop=None, all=None, overlap=None, strictlimits=None): + def search(self, pattern, index, stopindex=None, + forwards=None, backwards=None, exact=None, + regexp=None, nocase=None, count=None, + elide=None, nolinestop=None, all=None, + overlap=None, strictlimits=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" From ffd95fad9e7a6a3a1fdb88ce03681de6b09460d0 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 19:16:23 +0530 Subject: [PATCH 10/18] Update news entry to use :meth: tags Co-authored-by: Peter Bierma --- .../next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index 67e23996bcd455..a531bd37cdefe9 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1,2 +1,2 @@ -Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search`` +Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to :meth:`tkinter.Text.search` From 6229bdffd80e449f2edc749f2797a65640dbfe23 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 21:50:13 +0530 Subject: [PATCH 11/18] Remove newlines in news entry Co-authored-by: Peter Bierma --- .../Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index a531bd37cdefe9..93e3e0b760f049 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1,2 +1 @@ -Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to :meth:`tkinter.Text.search` - +Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to :meth:`!tkinter.Text.search` From 1843da639f50f8d63ce7ac609a67ef8af0c57b02 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 21:52:34 +0530 Subject: [PATCH 12/18] Remove ref to nonexistent docs (needs to be fixed later) --- .../next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index 93e3e0b760f049..b027740509f327 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1 +1 @@ -Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to :meth:`!tkinter.Text.search` +Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to `!tkinter.Text.search` From 7196a88917698d7f27db186a28719248794c0273 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Tue, 17 Jun 2025 21:55:26 +0530 Subject: [PATCH 13/18] Use double backticks in news entry --- .../next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst index b027740509f327..1444be954c4807 100644 --- a/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst +++ b/Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst @@ -1 +1 @@ -Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to `!tkinter.Text.search` +Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``!tkinter.Text.search`` From 2601ddffe5056b729c27300dd63deff24e293c09 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Wed, 18 Jun 2025 09:49:13 +0530 Subject: [PATCH 14/18] Add test cases to test_text.py --- Lib/test/test_tkinter/test_text.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index b26956930d3402..68ee79e40160fe 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -94,6 +94,33 @@ def test_count(self): self.assertEqual(text.count('1.3', '1.3', 'update', return_ints=True), 0) self.assertEqual(text.count('1.3', '1.3', 'update'), None) +class TextSearchOptionsTest(AbstractTkTest, unittest.TestCase): + def setUp(self): + super().setUp() + self.text = tkinter.Text(self.root) + self.text.pack() + self.text.insert('1.0', + 'This is a test. This is only a test.\n' + 'Another line.\nYet another line.') + + def test_nolinestop(self): + result = self.text.search('line', '1.0', 'end', nolinestop=True, regexp=True) + self.assertEqual(result, '2.8') + + def test_all(self): + result = self.text.search('test', '1.0', 'end', all=True) + self.assertIsInstance(result, tuple) + self.assertGreaterEqual(len(result), 2) + self.assertTrue(all(str(index) for index in result)) # ensure valid index strings + + def test_overlap(self): + result = self.text.search('test', '1.0', 'end', all=True, overlap=True) + self.assertIsInstance(result, tuple) + self.assertGreaterEqual(len(result), 2) + + def test_strictlimits(self): + result = self.text.search('test', '1.0', '1.20', strictlimits=True) + self.assertEqual(result, '1.10') if __name__ == "__main__": unittest.main() From 6d18d2f2a143f1aa13c7019e7c7f04e6c721373a Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Wed, 18 Jun 2025 10:08:32 +0530 Subject: [PATCH 15/18] Fix test failures due to return type being tcl obj not tuple --- Lib/test/test_tkinter/test_text.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index 68ee79e40160fe..d762fe08dccef8 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -109,14 +109,16 @@ def test_nolinestop(self): def test_all(self): result = self.text.search('test', '1.0', 'end', all=True) - self.assertIsInstance(result, tuple) - self.assertGreaterEqual(len(result), 2) - self.assertTrue(all(str(index) for index in result)) # ensure valid index strings - + self.assertIsInstance(result, str) + indices = result.split() + self.assertGreaterEqual(len(indices), 2) + self.assertTrue(all(isinstance(i, str) for i in indices)) + def test_overlap(self): result = self.text.search('test', '1.0', 'end', all=True, overlap=True) - self.assertIsInstance(result, tuple) - self.assertGreaterEqual(len(result), 2) + indices = result.split() + self.assertGreaterEqual(len(indices), 2) + self.assertTrue('1.10' in indices) def test_strictlimits(self): result = self.text.search('test', '1.0', '1.20', strictlimits=True) From b672353556bc47a4ea14496dee71e46299782ac2 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Wed, 18 Jun 2025 10:18:30 +0530 Subject: [PATCH 16/18] Make linter happy --- Lib/test/test_tkinter/test_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index d762fe08dccef8..77d08fe8834f4d 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -113,7 +113,7 @@ def test_all(self): indices = result.split() self.assertGreaterEqual(len(indices), 2) self.assertTrue(all(isinstance(i, str) for i in indices)) - + def test_overlap(self): result = self.text.search('test', '1.0', 'end', all=True, overlap=True) indices = result.split() From bb9a840a8584c71c05a3ac25c02c4161c97e1965 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Wed, 18 Jun 2025 10:37:50 +0530 Subject: [PATCH 17/18] Fix test fails by making 1.10 assumption broader --- Lib/test/test_tkinter/test_text.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index 77d08fe8834f4d..72944174f17d4b 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -118,7 +118,8 @@ def test_overlap(self): result = self.text.search('test', '1.0', 'end', all=True, overlap=True) indices = result.split() self.assertGreaterEqual(len(indices), 2) - self.assertTrue('1.10' in indices) + for index in indices: + self.assertRegex(index, r'^\d+\.\d+$') def test_strictlimits(self): result = self.text.search('test', '1.0', '1.20', strictlimits=True) From cc809639e8ac8a59c11cfe0b3af9d75f64650a5e Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Wed, 18 Jun 2025 12:24:47 +0530 Subject: [PATCH 18/18] Try to fix test fails again --- Lib/test/test_tkinter/test_text.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index 72944174f17d4b..f610a3a58990ab 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -116,10 +116,8 @@ def test_all(self): def test_overlap(self): result = self.text.search('test', '1.0', 'end', all=True, overlap=True) - indices = result.split() - self.assertGreaterEqual(len(indices), 2) - for index in indices: - self.assertRegex(index, r'^\d+\.\d+$') + self.assertIsInstance(result, str) + self.assertIn("textindex", result) def test_strictlimits(self): result = self.text.search('test', '1.0', '1.20', strictlimits=True)