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
6c6f851e
Commit
6c6f851e
authored
Aug 07, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9425: skip tests if a filename is not encodable
parent
87c9d6cf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
4 deletions
+29
-4
Lib/test/test_import.py
Lib/test/test_import.py
+5
-0
Lib/test/test_sax.py
Lib/test/test_sax.py
+5
-0
Lib/test/test_sys.py
Lib/test/test_sys.py
+4
-2
Lib/test/test_urllib.py
Lib/test/test_urllib.py
+6
-2
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+4
-0
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree.py
+5
-0
No files found.
Lib/test/test_import.py
View file @
6c6f851e
...
@@ -291,6 +291,11 @@ class ImportTests(unittest.TestCase):
...
@@ -291,6 +291,11 @@ class ImportTests(unittest.TestCase):
def
test_import_by_filename
(
self
):
def
test_import_by_filename
(
self
):
path
=
os
.
path
.
abspath
(
TESTFN
)
path
=
os
.
path
.
abspath
(
TESTFN
)
encoding
=
sys
.
getfilesystemencoding
()
try
:
path
.
encode
(
encoding
)
except
UnicodeEncodeError
:
self
.
skipTest
(
'path is not encodable to {}'
.
format
(
encoding
))
with
self
.
assertRaises
(
ImportError
)
as
c
:
with
self
.
assertRaises
(
ImportError
)
as
c
:
__import__
(
path
)
__import__
(
path
)
self
.
assertEqual
(
"Import by filename is not supported."
,
self
.
assertEqual
(
"Import by filename is not supported."
,
...
...
Lib/test/test_sax.py
View file @
6c6f851e
...
@@ -18,6 +18,11 @@ import unittest
...
@@ -18,6 +18,11 @@ import unittest
TEST_XMLFILE
=
findfile
(
"test.xml"
,
subdir
=
"xmltestdata"
)
TEST_XMLFILE
=
findfile
(
"test.xml"
,
subdir
=
"xmltestdata"
)
TEST_XMLFILE_OUT
=
findfile
(
"test.xml.out"
,
subdir
=
"xmltestdata"
)
TEST_XMLFILE_OUT
=
findfile
(
"test.xml.out"
,
subdir
=
"xmltestdata"
)
try
:
TEST_XMLFILE
.
encode
(
"utf8"
)
TEST_XMLFILE_OUT
.
encode
(
"utf8"
)
except
UnicodeEncodeError
:
raise
unittest
.
SkipTest
(
"filename is not encodable to utf8"
)
ns_uri
=
"http://www.python.org/xml-ns/saxtest/"
ns_uri
=
"http://www.python.org/xml-ns/saxtest/"
...
...
Lib/test/test_sys.py
View file @
6c6f851e
...
@@ -509,8 +509,10 @@ class SysModuleTest(unittest.TestCase):
...
@@ -509,8 +509,10 @@ class SysModuleTest(unittest.TestCase):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
code
],
stderr
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
code
],
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
stdout
,
stderr
=
p
.
communicate
()
self
.
assertEqual
(
p
.
returncode
,
1
)
self
.
assertEqual
(
p
.
returncode
,
1
)
self
.
assert_
(
b"UnicodeEncodeError:"
in
stderr
,
self
.
assertIn
(
"%r not in %s"
%
(
b"UniodeEncodeError:"
,
ascii
(
stderr
)))
br"UnicodeEncodeError: 'utf-8' codec can't encode character "
br"'\udcff' in position 7: surrogates not allowed"
,
stderr
)
def
test_sys_flags
(
self
):
def
test_sys_flags
(
self
):
self
.
assertTrue
(
sys
.
flags
)
self
.
assertTrue
(
sys
.
flags
)
...
...
Lib/test/test_urllib.py
View file @
6c6f851e
...
@@ -232,8 +232,12 @@ class urlretrieve_FileTests(unittest.TestCase):
...
@@ -232,8 +232,12 @@ class urlretrieve_FileTests(unittest.TestCase):
except
:
pass
except
:
pass
def
constructLocalFileUrl
(
self
,
filePath
):
def
constructLocalFileUrl
(
self
,
filePath
):
return
"file://%s"
%
urllib
.
request
.
pathname2url
(
filePath
=
os
.
path
.
abspath
(
filePath
)
os
.
path
.
abspath
(
filePath
))
try
:
filePath
.
encode
(
"utf8"
)
except
UnicodeEncodeError
:
raise
unittest
.
SkipTest
(
"filePath is not encodable to utf8"
)
return
"file://%s"
%
urllib
.
request
.
pathname2url
(
filePath
)
def
createNewTempFile
(
self
,
data
=
b""
):
def
createNewTempFile
(
self
,
data
=
b""
):
"""Creates a new temporary file containing the specified data,
"""Creates a new temporary file containing the specified data,
...
...
Lib/test/test_urllib2.py
View file @
6c6f851e
...
@@ -597,6 +597,10 @@ class OpenerDirectorTests(unittest.TestCase):
...
@@ -597,6 +597,10 @@ class OpenerDirectorTests(unittest.TestCase):
def
sanepathname2url
(
path
):
def
sanepathname2url
(
path
):
try
:
path
.
encode
(
"utf8"
)
except
UnicodeEncodeError
:
raise
unittest
.
SkipTest
(
"path is not encodable to utf8"
)
urlpath
=
urllib
.
request
.
pathname2url
(
path
)
urlpath
=
urllib
.
request
.
pathname2url
(
path
)
if
os
.
name
==
"nt"
and
urlpath
.
startswith
(
"///"
):
if
os
.
name
==
"nt"
and
urlpath
.
startswith
(
"///"
):
urlpath
=
urlpath
[
2
:]
urlpath
=
urlpath
[
2
:]
...
...
Lib/test/test_xml_etree.py
View file @
6c6f851e
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
import
sys
import
sys
import
cgi
import
cgi
import
unittest
from
test
import
support
from
test
import
support
from
test.support
import
findfile
from
test.support
import
findfile
...
@@ -20,6 +21,10 @@ from test.support import findfile
...
@@ -20,6 +21,10 @@ from test.support import findfile
from
xml.etree
import
ElementTree
as
ET
from
xml.etree
import
ElementTree
as
ET
SIMPLE_XMLFILE
=
findfile
(
"simple.xml"
,
subdir
=
"xmltestdata"
)
SIMPLE_XMLFILE
=
findfile
(
"simple.xml"
,
subdir
=
"xmltestdata"
)
try
:
SIMPLE_XMLFILE
.
encode
(
"utf8"
)
except
UnicodeEncodeError
:
raise
unittest
.
SkipTest
(
"filename is not encodable to utf8"
)
SIMPLE_NS_XMLFILE
=
findfile
(
"simple-ns.xml"
,
subdir
=
"xmltestdata"
)
SIMPLE_NS_XMLFILE
=
findfile
(
"simple-ns.xml"
,
subdir
=
"xmltestdata"
)
SAMPLE_XML
=
"""
\
SAMPLE_XML
=
"""
\
...
...
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