diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-05 06:20:15 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-11-05 06:20:15 (GMT) |
commit | 7529620a15939a5d4a4405aedb0a8bb17cc35d28 (patch) | |
tree | db7c48a1d9fa9859370ad5a14eef9481fdfca0b8 | |
parent | 33f13ee133ddec66c29c4e4ba091022038157a80 (diff) | |
download | cpython-7529620a15939a5d4a4405aedb0a8bb17cc35d28.zip cpython-7529620a15939a5d4a4405aedb0a8bb17cc35d28.tar.gz cpython-7529620a15939a5d4a4405aedb0a8bb17cc35d28.tar.bz2 |
Issue #16218: Fix test for issue again
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 86dfc73..750cf44 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -363,25 +363,26 @@ class CmdLineTest(unittest.TestCase): self.assertTrue(text[1].startswith(' File ')) self.assertTrue(text[3].startswith('NameError')) - def test_non_utf8(self): + def test_non_ascii(self): # Issue #16218 - with temp_dir() as script_dir: - script_basename = '\u0441\u043a\u0440\u0438\u043f\u0442' - try: - script_basename.encode(sys.getfilesystemencoding()) - except UnicodeEncodeError: - raise unittest.SkipTest("Filesystem doesn't support " - "unicode names") - source = 'print("test output")\n' - script_name = _make_test_script(script_dir, script_basename, source) - if not __debug__: - run_args = ('-' + 'O' * sys.flags.optimize, script_name) - else: - run_args = (script_name,) - rc, out, _ = assert_python_ok(*run_args) - self.assertEqual(0, rc) - expected = ("test output" + os.linesep).encode('ascii') - self.assertEqual(expected, out) + # non-ascii filename encodable to cp1252, cp932, latin1 and utf8 + filename = support.TESTFN + '\xa3.py' + try: + os.fsencode(filename) + except UnicodeEncodeError: + self.skipTest( + "Filesystem encoding %r cannot encode " + "the filename: %a" + % (sys.getfilesystemencoding(), filename)) + source = 'print(ascii(__file__))\n' + script_name = _make_test_script(os.curdir, filename, source) + self.addCleanup(support.unlink, script_name) + rc, stdout, stderr = assert_python_ok(script_name) + self.assertEqual( + ascii(script_name), + stdout.rstrip().decode('ascii'), + 'stdout=%r stderr=%r' % (stdout, stderr)) + self.assertEqual(0, rc) def test_main(): |