Make test_cmd_line work with strict str/bytes.
authorGuido van Rossum <guido@python.org>
Wed, 29 Aug 2007 03:47:36 +0000 (03:47 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 29 Aug 2007 03:47:36 +0000 (03:47 +0000)
Lib/test/test_cmd_line.py

index 441df09121a0cde3af87e5bf8799712ffaa44f0a..7d4f2abf7158900cc30ad2f1a07940d13381fc1e 100644 (file)
@@ -35,7 +35,7 @@ class CmdLineTest(unittest.TestCase):
 
     def verify_valid_flag(self, cmd_line):
         data = self.start_python(cmd_line)
-        self.assertTrue(data == b'' or data.endswith('\n'))
+        self.assertTrue(data == b'' or data.endswith(b'\n'))
         self.assertTrue(b'Traceback' not in data)
 
     def test_environment(self):
@@ -58,7 +58,7 @@ class CmdLineTest(unittest.TestCase):
         self.assertTrue(b'usage' in self.start_python('-h'))
 
     def test_version(self):
-        version = 'Python %d.%d' % sys.version_info[:2]
+        version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
         self.assertTrue(self.start_python('-V').startswith(version))
 
     def test_run_module(self):
@@ -84,8 +84,8 @@ class CmdLineTest(unittest.TestCase):
         # Runs the timeit module and checks the __main__
         # namespace has been populated appropriately
         p = _spawn_python('-i', '-m', 'timeit', '-n', '1')
-        p.stdin.write('Timer\n')
-        p.stdin.write('exit()\n')
+        p.stdin.write(b'Timer\n')
+        p.stdin.write(b'exit()\n')
         data = _kill_python(p)
         self.assertTrue(data.find(b'1 loop') != -1)
         self.assertTrue(data.find(b'__main__.Timer') != -1)