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
b63c5607
Commit
b63c5607
authored
Aug 12, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close HTTP connections and responses in tests to avoid ResourceWarnings
parent
20843506
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
Lib/test/test_httplib.py
Lib/test/test_httplib.py
+11
-1
No files found.
Lib/test/test_httplib.py
View file @
b63c5607
...
...
@@ -1402,6 +1402,7 @@ class HTTPSTest(TestCase):
resp
=
h
.
getresponse
()
h
.
close
()
self
.
assertIn
(
'nginx'
,
resp
.
getheader
(
'server'
))
resp
.
close
()
@
support
.
system_must_validate_cert
def
test_networked_trusted_by_default_cert
(
self
):
...
...
@@ -1412,6 +1413,7 @@ class HTTPSTest(TestCase):
h
.
request
(
'GET'
,
'/'
)
resp
=
h
.
getresponse
()
content_type
=
resp
.
getheader
(
'content-type'
)
resp
.
close
()
h
.
close
()
self
.
assertIn
(
'text/html'
,
content_type
)
...
...
@@ -1427,6 +1429,7 @@ class HTTPSTest(TestCase):
h
.
request
(
'GET'
,
'/'
)
resp
=
h
.
getresponse
()
server_string
=
resp
.
getheader
(
'server'
)
resp
.
close
()
h
.
close
()
self
.
assertIn
(
'nginx'
,
server_string
)
...
...
@@ -1460,8 +1463,10 @@ class HTTPSTest(TestCase):
context
.
verify_mode
=
ssl
.
CERT_REQUIRED
context
.
load_verify_locations
(
CERT_localhost
)
h
=
client
.
HTTPSConnection
(
'localhost'
,
server
.
port
,
context
=
context
)
self
.
addCleanup
(
h
.
close
)
h
.
request
(
'GET'
,
'/nonexistent'
)
resp
=
h
.
getresponse
()
self
.
addCleanup
(
resp
.
close
)
self
.
assertEqual
(
resp
.
status
,
404
)
def
test_local_bad_hostname
(
self
):
...
...
@@ -1486,13 +1491,18 @@ class HTTPSTest(TestCase):
check_hostname
=
False
)
h
.
request
(
'GET'
,
'/nonexistent'
)
resp
=
h
.
getresponse
()
resp
.
close
()
h
.
close
()
self
.
assertEqual
(
resp
.
status
,
404
)
# The context's check_hostname setting is used if one isn't passed to
# HTTPSConnection.
context
.
check_hostname
=
False
h
=
client
.
HTTPSConnection
(
'localhost'
,
server
.
port
,
context
=
context
)
h
.
request
(
'GET'
,
'/nonexistent'
)
self
.
assertEqual
(
h
.
getresponse
().
status
,
404
)
resp
=
h
.
getresponse
()
self
.
assertEqual
(
resp
.
status
,
404
)
resp
.
close
()
h
.
close
()
# Passing check_hostname to HTTPSConnection should override the
# context's setting.
h
=
client
.
HTTPSConnection
(
'localhost'
,
server
.
port
,
context
=
context
,
...
...
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