diff -r 347647a1f798 Lib/idlelib/RstripExtension.py --- a/Lib/idlelib/RstripExtension.py Mon Jun 24 18:12:57 2013 +0100 +++ b/Lib/idlelib/RstripExtension.py Mon Jun 24 19:03:44 2013 -0400 @@ -27,3 +27,8 @@ text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur) undo.undo_block_stop() + +if __name__ == "__main__": + import unittest + unittest.main('idlelib.idle_test.test_rstripextension', verbosity=2, exit=False) + diff -r 347647a1f798 Lib/idlelib/idle_test/test_rstripextension.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/idlelib/idle_test/test_rstripextension.py Mon Jun 24 19:03:44 2013 -0400 @@ -0,0 +1,49 @@ +import unittest +import textwrap +import idlelib.RstripExtension as rs +import idlelib.EditorWindow as ew +from tkinter.ttk import setup_master +from test.support import requires + +class Test_rstripextension(unittest.TestCase): + + @classmethod + def setUpClass(cls): + requires('gui') + + def setUp(self): + self.root = setup_master() + self.editwindow = ew.EditorWindow(root=self.root) + self.rstripextension = rs.RstripExtension(self.editwindow) + + def tearDown(self): + self.rstripextension = None + self.editwindow = None + self.root.destroy() + + def test_rstrip(self): + # Note: Tkinter always adds a newline at the end of the text widget, + # hence the newline in the expected_text string + + test_text = textwrap.dedent("""\ + Here is + some text + that has + whitespace at the end + of each line. """) + + expected_text = textwrap.dedent("""\ + Here is + some text + that has + whitespace at the end + of each line.\n""") + + self.editwindow.text.insert(1.0, test_text) + self.rstripextension.do_rstrip() + test_text = self.editwindow.text.get(1.0, "end") + self.assertEqual(test_text, expected_text) + +if __name__ == '__main__': + unittest.main(verbosity=2, exit=False) +