Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
09c449c7
Commit
09c449c7
authored
Aug 13, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a typo: TESTFN_UNENCODEABLE => TESTFN_UNENCODABLE
parent
042b128f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
Lib/test/support.py
Lib/test/support.py
+8
-8
Lib/test/test_imp.py
Lib/test/test_imp.py
+2
-2
Lib/test/test_unicode_file.py
Lib/test/test_unicode_file.py
+6
-6
No files found.
Lib/test/support.py
View file @
09c449c7
...
...
@@ -383,37 +383,37 @@ TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
TESTFN_UNICODE
=
TESTFN
+
"-
\
xe0
\
xf2
"
TESTFN_ENCODING
=
sys
.
getfilesystemencoding
()
# TESTFN_UNENCOD
E
ABLE 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
# cannot generate such filename.
if
os
.
name
in
(
'nt'
,
'ce'
):
if
sys
.
getwindowsversion
().
platform
<
2
:
# win32s (0) or Windows 9x/ME (1)
TESTFN_UNENCOD
E
ABLE
=
None
TESTFN_UNENCODABLE
=
None
else
:
# Japanese characters (I think - from bug 846133)
TESTFN_UNENCOD
E
ABLE
=
TESTFN
+
"-
\
u5171
\
u6709
\
u3055
\
u308c
\
u308b
"
TESTFN_UNENCODABLE
=
TESTFN
+
"-
\
u5171
\
u6709
\
u3055
\
u308c
\
u308b
"
try
:
TESTFN_UNENCOD
E
ABLE
.
encode
(
TESTFN_ENCODING
)
TESTFN_UNENCODABLE
.
encode
(
TESTFN_ENCODING
)
except
UnicodeEncodeError
:
pass
else
:
print
(
'WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
'Unicode filename tests may not be effective'
%
(
TESTFN_UNENCOD
E
ABLE
,
TESTFN_ENCODING
))
TESTFN_UNENCOD
E
ABLE
=
None
%
(
TESTFN_UNENCODABLE
,
TESTFN_ENCODING
))
TESTFN_UNENCODABLE
=
None
else
:
try
:
# ascii and utf-8 cannot encode the byte 0xff
b'
\
xff
'
.
decode
(
TESTFN_ENCODING
)
except
UnicodeDecodeError
:
# 0xff will be encoded using the surrogate character u+DCFF
TESTFN_UNENCOD
E
ABLE
=
TESTFN
\
TESTFN_UNENCODABLE
=
TESTFN
\
+
b'-
\
xff
'
.
decode
(
TESTFN_ENCODING
,
'surrogateescape'
)
else
:
# File system encoding (eg. ISO-8859-* encodings) can encode
# the byte 0xff. Skip some unicode filename tests.
TESTFN_UNENCOD
E
ABLE
=
None
TESTFN_UNENCODABLE
=
None
# Save the initial cwd
SAVEDCWD
=
os
.
getcwd
()
...
...
Lib/test/test_imp.py
View file @
09c449c7
...
...
@@ -307,10 +307,10 @@ class PEP3147Tests(unittest.TestCase):
class
NullImporterTests
(
unittest
.
TestCase
):
@
unittest
.
skipIf
(
support
.
TESTFN_UNENCOD
E
ABLE
is
None
,
@
unittest
.
skipIf
(
support
.
TESTFN_UNENCODABLE
is
None
,
"Need an undecodeable filename"
)
def
test_unencodeable
(
self
):
name
=
support
.
TESTFN_UNENCOD
E
ABLE
name
=
support
.
TESTFN_UNENCODABLE
os
.
mkdir
(
name
)
try
:
self
.
assertRaises
(
ImportError
,
imp
.
NullImporter
,
name
)
...
...
Lib/test/test_unicode_file.py
View file @
09c449c7
...
...
@@ -6,7 +6,7 @@ import unicodedata
import
unittest
from
test.support
import
(
run_unittest
,
rmtree
,
TESTFN_ENCODING
,
TESTFN_UNICODE
,
TESTFN_UNENCOD
E
ABLE
)
TESTFN_ENCODING
,
TESTFN_UNICODE
,
TESTFN_UNENCODABLE
)
try
:
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
def
test_single_files
(
self
):
self
.
_test_single
(
TESTFN_UNICODE
)
if
TESTFN_UNENCOD
E
ABLE
is
not
None
:
self
.
_test_single
(
TESTFN_UNENCOD
E
ABLE
)
if
TESTFN_UNENCODABLE
is
not
None
:
self
.
_test_single
(
TESTFN_UNENCODABLE
)
def
test_directories
(
self
):
# For all 'equivalent' combinations:
...
...
@@ -157,9 +157,9 @@ class TestUnicodeFiles(unittest.TestCase):
ext
=
".dir"
self
.
_do_directory
(
TESTFN_UNICODE
+
ext
,
TESTFN_UNICODE
+
ext
,
False
)
# Our directory name that can't use a non-unicode name.
if
TESTFN_UNENCOD
E
ABLE
is
not
None
:
self
.
_do_directory
(
TESTFN_UNENCOD
E
ABLE
+
ext
,
TESTFN_UNENCOD
E
ABLE
+
ext
,
if
TESTFN_UNENCODABLE
is
not
None
:
self
.
_do_directory
(
TESTFN_UNENCODABLE
+
ext
,
TESTFN_UNENCODABLE
+
ext
,
False
)
def
test_main
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment