summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_cmd.py')
-rw-r--r--Lib/test/test_cmd.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index 19ee52e..c46fec8 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -8,6 +8,9 @@ Original by Michael Schneider
import cmd
import sys
from test import test_support
+import re
+import unittest
+import StringIO
class samplecmdclass(cmd.Cmd):
"""
@@ -168,9 +171,33 @@ class samplecmdclass(cmd.Cmd):
def do_exit(self, arg):
return True
+
+class TestAlternateInput(unittest.TestCase):
+
+ class simplecmd(cmd.Cmd):
+
+ def do_print(self, args):
+ print >>self.stdout, args
+
+ def do_EOF(self, args):
+ return True
+
+ def test_file_with_missing_final_nl(self):
+ input = StringIO.StringIO("print test\nprint test2")
+ output = StringIO.StringIO()
+ cmd = self.simplecmd(stdin=input, stdout=output)
+ cmd.use_rawinput = False
+ cmd.cmdloop()
+ self.assertMultiLineEqual(output.getvalue(),
+ ("(Cmd) test\n"
+ "(Cmd) test2\n"
+ "(Cmd) "))
+
+
def test_main(verbose=None):
from test import test_cmd
test_support.run_doctest(test_cmd, verbose)
+ test_support.run_unittest(TestAlternateInput)
def test_coverage(coverdir):
trace = test_support.import_module('trace')