Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/integration/test_httpbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

pytestmark = pytest.mark.integration

# Go reports a timeout as "Client.Timeout exceeded" or "context deadline exceeded", depending on where it hits.
TIMEOUT = "Timeout exceeded|deadline exceeded"


@pytest.fixture
def session() -> Iterator[Session]:
Expand Down Expand Up @@ -241,14 +244,14 @@ def test_refused_connection_raises(self, session):
def test_session_timeout_raises(self, httpbin, session):
session.timeout_seconds = 1

with pytest.raises(TLSClientException, match="Timeout exceeded"):
with pytest.raises(TLSClientException, match=TIMEOUT):
session.get(f"{httpbin.url}/delay/2")

@pytest.mark.parametrize("kwarg", ["timeout", "timeout_seconds"])
def test_request_timeout_applies_after_the_first_request(self, httpbin, session, kwarg):
session.get(f"{httpbin.url}/get")

with pytest.raises(TLSClientException, match="Timeout exceeded"):
with pytest.raises(TLSClientException, match=TIMEOUT):
session.get(f"{httpbin.url}/delay/2", **{kwarg: 1})


Expand Down
6 changes: 4 additions & 2 deletions tests/integration/test_local_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
LARGE = os.urandom(8 * 1024 * 1024)
# How long /slow takes to answer.
SLOW_SECONDS = 0.6
# Go reports a timeout as "Client.Timeout exceeded" or "context deadline exceeded", depending on where it hits.
TIMEOUT = "Timeout exceeded|deadline exceeded"

# Path -> (Content-Type, body)
BODIES = {
Expand Down Expand Up @@ -166,7 +168,7 @@ def test_content_type_from_the_session_or_the_request_is_kept(self, server_url,
class TestTimeout:
@pytest.mark.parametrize("kwarg", ["timeout", "timeout_seconds"])
def test_fractional_timeout_is_applied(self, server_url, session, kwarg):
with pytest.raises(TLSClientException, match="Timeout exceeded"):
with pytest.raises(TLSClientException, match=TIMEOUT):
session.get(f"{server_url}/slow", **{kwarg: SLOW_SECONDS / 3})

def test_response_within_the_timeout_arrives(self, server_url, session):
Expand All @@ -175,7 +177,7 @@ def test_response_within_the_timeout_arrives(self, server_url, session):
def test_fractional_session_timeout_is_applied(self, server_url, session):
session.timeout_seconds = SLOW_SECONDS / 3

with pytest.raises(TLSClientException, match="Timeout exceeded"):
with pytest.raises(TLSClientException, match=TIMEOUT):
session.get(f"{server_url}/slow")


Expand Down
Loading