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

Method test_write

Lib/idlelib/idle_test/test_outwin.py:61–98  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

59 del w.get_saved
60
61 def test_write(self):
62 eq = self.assertEqual
63 delete = self.text.delete
64 get = self.text.get
65 write = self.window.write
66
67 # No new line - insert stays on same line.
68 delete('1.0', 'end')
69 test_text = 'test text'
70 eq(write(test_text), len(test_text))
71 eq(get('1.0', '1.end'), 'test text')
72 eq(get('insert linestart', 'insert lineend'), 'test text')
73
74 # New line - insert moves to next line.
75 delete('1.0', 'end')
76 test_text = 'test text\n'
77 eq(write(test_text), len(test_text))
78 eq(get('1.0', '1.end'), 'test text')
79 eq(get('insert linestart', 'insert lineend'), '')
80
81 # Text after new line is tagged for second line of Text widget.
82 delete('1.0', 'end')
83 test_text = 'test text\nLine 2'
84 eq(write(test_text), len(test_text))
85 eq(get('1.0', '1.end'), 'test text')
86 eq(get('2.0', '2.end'), 'Line 2')
87 eq(get('insert linestart', 'insert lineend'), 'Line 2')
88
89 # Test tags.
90 delete('1.0', 'end')
91 test_text = 'test text\n'
92 test_text2 = 'Line 2\n'
93 eq(write(test_text, tags='mytag'), len(test_text))
94 eq(write(test_text2, tags='secondtag'), len(test_text2))
95 eq(get('mytag.first', 'mytag.last'), test_text)
96 eq(get('secondtag.first', 'secondtag.last'), test_text2)
97 eq(get('1.0', '1.end'), test_text.rstrip('\n'))
98 eq(get('2.0', '2.end'), test_text2.rstrip('\n'))
99
100 def test_writelines(self):
101 eq = self.assertEqual

Callers

nothing calls this directly

Calls 5

deleteClass · 0.85
eqFunction · 0.85
writeFunction · 0.50
getFunction · 0.50
rstripMethod · 0.45

Tested by

no test coverage detected