summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-02-19 02:54:29 (GMT)
committerJesus Cea <jcea@jcea.es>2012-02-19 02:54:29 (GMT)
commitfbc6f943e011397a8523617babc4a438b4df6bb6 (patch)
treed7e25622e9cbe616ceaf037b57ad72ee2d1118ee /Lib
parentc33ae06cbf9deae1ef6bb56d59c710c0b55b61f0 (diff)
downloadcpython-fbc6f943e011397a8523617babc4a438b4df6bb6.zip
cpython-fbc6f943e011397a8523617babc4a438b4df6bb6.tar.gz
cpython-fbc6f943e011397a8523617babc4a438b4df6bb6.tar.bz2
Test for issue #13500
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_cmd.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index a1799f9..3a46355 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -180,6 +180,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 = io.StringIO("print test\nprint test2")
output = io.StringIO()
@@ -192,6 +200,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
support.run_doctest(test_cmd, verbose)