MCPcopy Index your code
hub / github.com/python/cpython / test_paren_styles

Method test_paren_styles

Lib/idlelib/idle_test/test_parenmatch.py:48–80  ·  view source on GitHub ↗

Test ParenMatch with each style.

(self)

Source from the content-addressed store, hash-verified

46 return pm
47
48 def test_paren_styles(self):
49 """
50 Test ParenMatch with each style.
51 """
52 text = self.text
53 pm = self.get_parenmatch()
54 for style, range1, range2 in (
55 ('opener', ('1.10', '1.11'), ('1.10', '1.11')),
56 ('default',('1.10', '1.11'),('1.10', '1.11')),
57 ('parens', ('1.14', '1.15'), ('1.15', '1.16')),
58 ('expression', ('1.10', '1.15'), ('1.10', '1.16'))):
59 with self.subTest(style=style):
60 text.delete('1.0', 'end')
61 pm.STYLE = style
62 text.insert('insert', 'def foobar(a, b')
63
64 pm.flash_paren_event('event')
65 self.assertIn('<<parenmatch-check-restore>>', text.event_info())
66 if style == 'parens':
67 self.assertTupleEqual(text.tag_nextrange('paren', '1.0'),
68 ('1.10', '1.11'))
69 self.assertTupleEqual(
70 text.tag_prevrange('paren', 'end'), range1)
71
72 text.insert('insert', ')')
73 pm.restore_event()
74 self.assertNotIn('<<parenmatch-check-restore>>',
75 text.event_info())
76 self.assertEqual(text.tag_prevrange('paren', 'end'), ())
77
78 pm.paren_closed_event('event')
79 self.assertTupleEqual(
80 text.tag_prevrange('paren', 'end'), range2)
81
82 def test_paren_corner(self):
83 """

Callers

nothing calls this directly

Calls 14

get_parenmatchMethod · 0.95
flash_paren_eventMethod · 0.80
assertInMethod · 0.80
assertTupleEqualMethod · 0.80
tag_nextrangeMethod · 0.80
tag_prevrangeMethod · 0.80
restore_eventMethod · 0.80
assertNotInMethod · 0.80
paren_closed_eventMethod · 0.80
subTestMethod · 0.45
deleteMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected