Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
6578a95f
Commit
6578a95f
authored
Feb 21, 2019
by
juga
Browse files
tests: Add test to check get/head timeout
Closes:
#29551
. Bugfix 1.0.3-dev0.
parent
1cc8351c
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/integration/util/test_requests.py
0 → 100644
View file @
6578a95f
"""Integration tests for requests."""
import
requests
import
uuid
from
sbws
import
settings
from
sbws.util
import
requests
as
requests_utils
def
test_make_session
(
conf
,
persistent_launch_tor
,
dests
):
uuid_str
=
str
(
uuid
.
uuid4
())
settings
.
init_http_headers
(
conf
.
get
(
'scanner'
,
'nickname'
),
uuid_str
,
str
(
persistent_launch_tor
.
get_version
()))
session
=
requests_utils
.
make_session
(
persistent_launch_tor
,
conf
.
getfloat
(
'general'
,
'http_timeout'
))
assert
session
.
_timeout
==
conf
.
getfloat
(
'general'
,
'http_timeout'
)
# Because there is not an stream attached to a circuit, this will timeout.
response
=
None
try
:
response
=
session
.
get
(
dests
.
next
().
url
,
verify
=
False
)
except
requests
.
exceptions
.
ConnectTimeout
:
pass
assert
response
is
None
# Disable socks proxies to test a session request not over Tor
# without timeout.
session
.
proxies
=
{}
response
=
session
.
get
(
dests
.
next
().
url
,
verify
=
False
)
print
(
response
.
request
.
__dict__
)
Write
Preview
Supports
Markdown
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