diff -r ffb58df8f9ea Lib/test/test_cmd.py --- a/Lib/test/test_cmd.py Mon Jan 16 18:02:21 2012 -0500 +++ b/Lib/test/test_cmd.py Tue Jan 17 00:03:48 2012 -0800 @@ -180,6 +180,14 @@ def do_EOF(self, args): return True + + class simplecmd2(simplecmd): + + def do_EOF(self, args): + print('*** Unknown syntax: EOF', file=self.stdout) + return True + + def test_file_with_missing_final_nl(self): input = io.StringIO("print test\nprint test2") output = io.StringIO() @@ -192,6 +200,27 @@ "(Cmd) ")) + def test_input_reset_at_EOF(self): + input = io.StringIO("print test\nprint test2") + output = io.StringIO() + cmd = self.simplecmd2(stdin=input, stdout=output) + cmd.use_rawinput = False + cmd.cmdloop() + self.assertMultiLineEqual(output.getvalue(), + ("(Cmd) test\n" + "(Cmd) test2\n" + "(Cmd) *** Unknown syntax: EOF\n")) + input = io.StringIO("print \n\n") + output = io.StringIO() + cmd.stdin = input + cmd.stdout = output + cmd.cmdloop() + self.assertMultiLineEqual(output.getvalue(), + ("(Cmd) \n" + "(Cmd) \n" + "(Cmd) *** Unknown syntax: EOF\n")) + + def test_main(verbose=None): from test import test_cmd support.run_doctest(test_cmd, verbose)