mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix a typo: TESTFN_UNENCODEABLE => TESTFN_UNENCODABLE
This commit is contained in:
parent
042b128f58
commit
09c449c7de
3 changed files with 16 additions and 16 deletions
|
@ -383,37 +383,37 @@ TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
|
||||||
TESTFN_UNICODE = TESTFN + "-\xe0\xf2"
|
TESTFN_UNICODE = TESTFN + "-\xe0\xf2"
|
||||||
TESTFN_ENCODING = sys.getfilesystemencoding()
|
TESTFN_ENCODING = sys.getfilesystemencoding()
|
||||||
|
|
||||||
# TESTFN_UNENCODEABLE is a filename (str type) that should *not* be able to be
|
# TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
|
||||||
# encoded by the filesystem encoding (in strict mode). It can be None if we
|
# encoded by the filesystem encoding (in strict mode). It can be None if we
|
||||||
# cannot generate such filename.
|
# cannot generate such filename.
|
||||||
if os.name in ('nt', 'ce'):
|
if os.name in ('nt', 'ce'):
|
||||||
if sys.getwindowsversion().platform < 2:
|
if sys.getwindowsversion().platform < 2:
|
||||||
# win32s (0) or Windows 9x/ME (1)
|
# win32s (0) or Windows 9x/ME (1)
|
||||||
TESTFN_UNENCODEABLE = None
|
TESTFN_UNENCODABLE = None
|
||||||
else:
|
else:
|
||||||
# Japanese characters (I think - from bug 846133)
|
# Japanese characters (I think - from bug 846133)
|
||||||
TESTFN_UNENCODEABLE = TESTFN + "-\u5171\u6709\u3055\u308c\u308b"
|
TESTFN_UNENCODABLE = TESTFN + "-\u5171\u6709\u3055\u308c\u308b"
|
||||||
try:
|
try:
|
||||||
TESTFN_UNENCODEABLE.encode(TESTFN_ENCODING)
|
TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
|
print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
|
||||||
'Unicode filename tests may not be effective'
|
'Unicode filename tests may not be effective'
|
||||||
% (TESTFN_UNENCODEABLE, TESTFN_ENCODING))
|
% (TESTFN_UNENCODABLE, TESTFN_ENCODING))
|
||||||
TESTFN_UNENCODEABLE = None
|
TESTFN_UNENCODABLE = None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# ascii and utf-8 cannot encode the byte 0xff
|
# ascii and utf-8 cannot encode the byte 0xff
|
||||||
b'\xff'.decode(TESTFN_ENCODING)
|
b'\xff'.decode(TESTFN_ENCODING)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
# 0xff will be encoded using the surrogate character u+DCFF
|
# 0xff will be encoded using the surrogate character u+DCFF
|
||||||
TESTFN_UNENCODEABLE = TESTFN \
|
TESTFN_UNENCODABLE = TESTFN \
|
||||||
+ b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
|
+ b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
|
||||||
else:
|
else:
|
||||||
# File system encoding (eg. ISO-8859-* encodings) can encode
|
# File system encoding (eg. ISO-8859-* encodings) can encode
|
||||||
# the byte 0xff. Skip some unicode filename tests.
|
# the byte 0xff. Skip some unicode filename tests.
|
||||||
TESTFN_UNENCODEABLE = None
|
TESTFN_UNENCODABLE = None
|
||||||
|
|
||||||
# Save the initial cwd
|
# Save the initial cwd
|
||||||
SAVEDCWD = os.getcwd()
|
SAVEDCWD = os.getcwd()
|
||||||
|
|
|
@ -307,10 +307,10 @@ class PEP3147Tests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class NullImporterTests(unittest.TestCase):
|
class NullImporterTests(unittest.TestCase):
|
||||||
@unittest.skipIf(support.TESTFN_UNENCODEABLE is None,
|
@unittest.skipIf(support.TESTFN_UNENCODABLE is None,
|
||||||
"Need an undecodeable filename")
|
"Need an undecodeable filename")
|
||||||
def test_unencodeable(self):
|
def test_unencodeable(self):
|
||||||
name = support.TESTFN_UNENCODEABLE
|
name = support.TESTFN_UNENCODABLE
|
||||||
os.mkdir(name)
|
os.mkdir(name)
|
||||||
try:
|
try:
|
||||||
self.assertRaises(ImportError, imp.NullImporter, name)
|
self.assertRaises(ImportError, imp.NullImporter, name)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import unicodedata
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import (run_unittest, rmtree,
|
from test.support import (run_unittest, rmtree,
|
||||||
TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODEABLE)
|
TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
TESTFN_UNICODE.encode(TESTFN_ENCODING)
|
TESTFN_UNICODE.encode(TESTFN_ENCODING)
|
||||||
|
@ -147,8 +147,8 @@ class TestUnicodeFiles(unittest.TestCase):
|
||||||
# _test functions with each of the filename combinations we wish to test
|
# _test functions with each of the filename combinations we wish to test
|
||||||
def test_single_files(self):
|
def test_single_files(self):
|
||||||
self._test_single(TESTFN_UNICODE)
|
self._test_single(TESTFN_UNICODE)
|
||||||
if TESTFN_UNENCODEABLE is not None:
|
if TESTFN_UNENCODABLE is not None:
|
||||||
self._test_single(TESTFN_UNENCODEABLE)
|
self._test_single(TESTFN_UNENCODABLE)
|
||||||
|
|
||||||
def test_directories(self):
|
def test_directories(self):
|
||||||
# For all 'equivalent' combinations:
|
# For all 'equivalent' combinations:
|
||||||
|
@ -157,9 +157,9 @@ class TestUnicodeFiles(unittest.TestCase):
|
||||||
ext = ".dir"
|
ext = ".dir"
|
||||||
self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
|
self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
|
||||||
# Our directory name that can't use a non-unicode name.
|
# Our directory name that can't use a non-unicode name.
|
||||||
if TESTFN_UNENCODEABLE is not None:
|
if TESTFN_UNENCODABLE is not None:
|
||||||
self._do_directory(TESTFN_UNENCODEABLE+ext,
|
self._do_directory(TESTFN_UNENCODABLE+ext,
|
||||||
TESTFN_UNENCODEABLE+ext,
|
TESTFN_UNENCODABLE+ext,
|
||||||
False)
|
False)
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue