Skip to content

Commit c0b7772

Browse files
authored
Enhance regex tests for text widget
Added tests for text.search with and without regex.
1 parent 6ef05e3 commit c0b7772

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_tkinter/test_text.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ def test_search(self):
4747
'Another line.\n'
4848
'Yet another line.')
4949

50-
result = text.search('line', '1.0', 'end', nolinestop=True, regexp=True)
51-
self.assertEqual(result, '2.8')
50+
result_plain = text.search('line', '1.0', 'end', nolinestop=True)
51+
self.assertEqual(result_plain, '2.8')
52+
53+
# With regexp (same literal pattern, should behave the same)
54+
result_regexp = text.search('line', '1.0', 'end', nolinestop=True, regexp=True)
55+
self.assertEqual(result_regexp, '2.8')
56+
57+
# With a true regex pattern (e.g. "l.n.") to show difference
58+
result_regex_pattern = text.search(r'l.n.', '1.0', 'end', nolinestop=True, regexp=True)
59+
self.assertEqual(result_regex_pattern, '2.8')
5260

5361
strict_res = text.search('test', '1.0', '1.20', strictlimits=True)
5462
self.assertEqual(strict_res, '1.10')

0 commit comments

Comments
 (0)