diff -r 7f17c67b5bf6 Lib/idlelib/FormatParagraph.py --- a/Lib/idlelib/FormatParagraph.py Sun Jul 07 17:35:11 2013 +0200 +++ b/Lib/idlelib/FormatParagraph.py Mon Jul 08 00:21:39 2013 -0400 @@ -149,3 +149,8 @@ m = re.match(r"^(\s*#*)", line) if m is None: return "" return m.group(1) + +if __name__ == "__main__": + import unittest + unittest.main('idlelib.idle_test.test_formatparagraph.py', verbosity=2, + exit=False) diff -r 7f17c67b5bf6 Lib/idlelib/idle_test/test_formatparagraph.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/idlelib/idle_test/test_formatparagraph.py Mon Jul 08 00:21:39 2013 -0400 @@ -0,0 +1,24 @@ +import unittest +from idlelib import FormatParagraph as format_paragraph +from idlelib.idle_test.mock_idle import Editor + +class FormatParagraphTest(unittest.TestCase): + + def test_reformat_paragrah(self): + '''tests the basic reformat_paragraph function without the editor window''' + reformat_result = format_paragraph.reformat_paragraph("# hello world" + , 8) + reformat_expected_result = ("# hello\nworld") + self.assertEqual(reformat_result, reformat_expected_result) + + def test_format_paragraph_event(self): + self.dummy_editor_window = Editor() + self.dummy_editor_window.text.insert('1.0'," \"\"\"this is a test of a reformat for a triple quoted string will it reformat to less than 80 characters for me?\"\"\"") + self.fp = format_paragraph.FormatParagraph(self.dummy_editor_window) + self.fp.format_paragraph_event('ParameterDoesNothing') + reformat_result = self.dummy_editor_window.text.get('1.0','end') + reformat_expected_result = (" \"\"\"this is a test of a reformat for a triple quoted string will\n it reformat to less than 80 characters for me?\"\"\"\n") + self.assertEqual(reformat_result, reformat_expected_result) + +if __name__ == '__main__': + unittest.main(verbosity=2, exit=2)