ยปCore Development>Code coverage>Lib/idlelib/idle_test/test_rstrip.py

Python code coverage for Lib/idlelib/idle_test/test_rstrip.py

#countcontent
1n/aimport unittest
2n/aimport idlelib.rstrip as rs
3n/afrom idlelib.idle_test.mock_idle import Editor
4n/a
5n/aclass rstripTest(unittest.TestCase):
6n/a
7n/a def test_rstrip_line(self):
8n/a editor = Editor()
9n/a text = editor.text
10n/a do_rstrip = rs.RstripExtension(editor).do_rstrip
11n/a
12n/a do_rstrip()
13n/a self.assertEqual(text.get('1.0', 'insert'), '')
14n/a text.insert('1.0', ' ')
15n/a do_rstrip()
16n/a self.assertEqual(text.get('1.0', 'insert'), '')
17n/a text.insert('1.0', ' \n')
18n/a do_rstrip()
19n/a self.assertEqual(text.get('1.0', 'insert'), '\n')
20n/a
21n/a def test_rstrip_multiple(self):
22n/a editor = Editor()
23n/a # Uncomment following to verify that test passes with real widgets.
24n/a## from idlelib.editor import EditorWindow as Editor
25n/a## from tkinter import Tk
26n/a## editor = Editor(root=Tk())
27n/a text = editor.text
28n/a do_rstrip = rs.RstripExtension(editor).do_rstrip
29n/a
30n/a original = (
31n/a "Line with an ending tab \n"
32n/a "Line ending in 5 spaces \n"
33n/a "Linewithnospaces\n"
34n/a " indented line\n"
35n/a " indented line with trailing space \n"
36n/a " ")
37n/a stripped = (
38n/a "Line with an ending tab\n"
39n/a "Line ending in 5 spaces\n"
40n/a "Linewithnospaces\n"
41n/a " indented line\n"
42n/a " indented line with trailing space\n")
43n/a
44n/a text.insert('1.0', original)
45n/a do_rstrip()
46n/a self.assertEqual(text.get('1.0', 'insert'), stripped)
47n/a
48n/aif __name__ == '__main__':
49n/a unittest.main(verbosity=2, exit=False)