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
f671de4d
Commit
f671de4d
authored
Nov 25, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't fail tests when www.python.org can't be validated by the system
parent
72275ef7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
Lib/test/test_httplib.py
Lib/test/test_httplib.py
+1
-3
Lib/test/test_robotparser.py
Lib/test/test_robotparser.py
+3
-2
Lib/test/test_support.py
Lib/test/test_support.py
+13
-0
No files found.
Lib/test/test_httplib.py
View file @
f671de4d
...
@@ -551,12 +551,10 @@ class HTTPSTest(TestCase):
...
@@ -551,12 +551,10 @@ class HTTPSTest(TestCase):
resp
=
h
.
getresponse
()
resp
=
h
.
getresponse
()
self
.
assertIn
(
'nginx'
,
resp
.
getheader
(
'server'
))
self
.
assertIn
(
'nginx'
,
resp
.
getheader
(
'server'
))
@
test_support
.
system_must_validate_cert
def
test_networked_trusted_by_default_cert
(
self
):
def
test_networked_trusted_by_default_cert
(
self
):
# Default settings: requires a valid cert from a trusted CA
# Default settings: requires a valid cert from a trusted CA
test_support
.
requires
(
'network'
)
test_support
.
requires
(
'network'
)
if
test_support
.
verbose
:
import
ssl
print
(
ssl
.
_create_default_https_context
().
get_ca_certs
())
with
test_support
.
transient_internet
(
'www.python.org'
):
with
test_support
.
transient_internet
(
'www.python.org'
):
h
=
httplib
.
HTTPSConnection
(
'www.python.org'
,
443
)
h
=
httplib
.
HTTPSConnection
(
'www.python.org'
,
443
)
h
.
request
(
'GET'
,
'/'
)
h
.
request
(
'GET'
,
'/'
)
...
...
Lib/test/test_robotparser.py
View file @
f671de4d
...
@@ -276,14 +276,15 @@ class NetworkTestCase(unittest.TestCase):
...
@@ -276,14 +276,15 @@ class NetworkTestCase(unittest.TestCase):
self
.
assertEqual
(
parser
.
can_fetch
(
"*"
,
robots_url
),
False
)
self
.
assertEqual
(
parser
.
can_fetch
(
"*"
,
robots_url
),
False
)
@
unittest
.
skipUnless
(
HAVE_HTTPS
,
'need SSL support to download license'
)
@
unittest
.
skipUnless
(
HAVE_HTTPS
,
'need SSL support to download license'
)
@
test_support
.
system_must_validate_cert
def
testPythonOrg
(
self
):
def
testPythonOrg
(
self
):
test_support
.
requires
(
'network'
)
test_support
.
requires
(
'network'
)
with
test_support
.
transient_internet
(
'www.python.org'
):
with
test_support
.
transient_internet
(
'www.python.org'
):
parser
=
robotparser
.
RobotFileParser
(
parser
=
robotparser
.
RobotFileParser
(
"http://www.python.org/robots.txt"
)
"http
s
://www.python.org/robots.txt"
)
parser
.
read
()
parser
.
read
()
self
.
assertTrue
(
self
.
assertTrue
(
parser
.
can_fetch
(
"*"
,
"http://www.python.org/robots.txt"
))
parser
.
can_fetch
(
"*"
,
"http
s
://www.python.org/robots.txt"
))
def
test_main
():
def
test_main
():
...
...
Lib/test/test_support.py
View file @
f671de4d
...
@@ -481,6 +481,19 @@ def _is_ipv6_enabled():
...
@@ -481,6 +481,19 @@ def _is_ipv6_enabled():
IPV6_ENABLED
=
_is_ipv6_enabled
()
IPV6_ENABLED
=
_is_ipv6_enabled
()
def
system_must_validate_cert
(
f
):
"""Skip the test on TLS certificate validation failures."""
@
functools
.
wraps
(
f
)
def
dec
(
*
args
,
**
kwargs
):
try
:
f
(
*
args
,
**
kwargs
)
except
IOError
as
e
:
if
e
.
reason
==
"CERTIFICATE_VERIFY_FAILED"
:
raise
unittest
.
SkipTest
(
"system does not contain "
"necessary certificates"
)
raise
return
dec
FUZZ
=
1e-6
FUZZ
=
1e-6
def
fcmp
(
x
,
y
):
# fuzzy comparison function
def
fcmp
(
x
,
y
):
# fuzzy comparison function
...
...
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