diff options
author | Jesus Cea <jcea@jcea.es> | 2012-02-19 02:54:08 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-02-19 02:54:08 (GMT) |
commit | 6e250998b6da145bd75f026a7e8add22bce9a95a (patch) | |
tree | aee4968dcfd84612e3313a8894dd4c13280340b1 /Lib | |
parent | c5df56304172d2d825fab27db97e6e90660cf7ef (diff) | |
download | cpython-6e250998b6da145bd75f026a7e8add22bce9a95a.zip cpython-6e250998b6da145bd75f026a7e8add22bce9a95a.tar.gz cpython-6e250998b6da145bd75f026a7e8add22bce9a95a.tar.bz2 |
Test for issue #13500
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_cmd.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index c46fec8..38288bb 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -182,6 +182,14 @@ class TestAlternateInput(unittest.TestCase): 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 = StringIO.StringIO("print test\nprint test2") output = StringIO.StringIO() @@ -194,6 +202,27 @@ class TestAlternateInput(unittest.TestCase): "(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 test_support.run_doctest(test_cmd, verbose) |