Issue #16218: Fix test for issue again
This commit is contained in:
parent
33f13ee133
commit
7529620a15
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue