mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
added timeout tests
This commit is contained in:
parent
167970cb65
commit
62e1713489
@ -11,7 +11,8 @@ class HTTP1Test < HTTPTest
|
||||
include WithChunkedBody
|
||||
include Headers
|
||||
include ResponseBody
|
||||
include IO
|
||||
include IO
|
||||
include Timeouts
|
||||
|
||||
include Plugins::Proxy
|
||||
include Plugins::Authentication
|
||||
|
@ -10,6 +10,7 @@ class HTTP2Test < HTTPTest
|
||||
include Headers
|
||||
include ResponseBody
|
||||
include IO
|
||||
include Timeouts
|
||||
|
||||
include Plugins::Proxy
|
||||
include Plugins::Authentication
|
||||
|
21
test/support/requests/timeouts.rb
Normal file
21
test/support/requests/timeouts.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Requests
|
||||
module Timeouts
|
||||
# def test_http_timeouts_loop_timeout
|
||||
# uri = build_uri("/delay/2")
|
||||
# client = HTTPX.timeout(loop_timeout: 1)
|
||||
# response = client.get(uri)
|
||||
# assert response.is_a?(HTTPX::ErrorResponse), "response should have failed"
|
||||
# assert response.error =~ /timed out while waiting/, "response should have timed out"
|
||||
# end
|
||||
|
||||
def test_http_timeouts_total_timeout
|
||||
uri = build_uri("/delay/3")
|
||||
client = HTTPX.timeout(loop_timeout: 1, total_timeout: 2)
|
||||
response = client.get(uri)
|
||||
assert response.is_a?(HTTPX::ErrorResponse), "response should have failed"
|
||||
assert response.error =~ /timed out after 2 seconds/i, "response should have timed out"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user