Skip to content

Commit

Permalink
testing if type annotation of list[RequestMap] was causing failures i…
Browse files Browse the repository at this point in the history
…n version below 3.10
  • Loading branch information
fullerzz committed Mar 2, 2024
1 parent ea7b53d commit 2c7a56f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from typing import List

import pytest

from src.loamy.session import Clump, RequestMap, RequestResponse


@pytest.fixture(scope="session")
def request_map_collection() -> list[RequestMap]:
requests: list[RequestMap] = []
def request_map_collection() -> List[RequestMap]:
requests: List[RequestMap] = []
for i in range(0, 100):
print(i)
if i % 2 == 0:
Expand Down Expand Up @@ -34,23 +36,23 @@ def request_map_to_trigger_exception() -> RequestMap:
)


def test_send_requests(request_map_collection: list[RequestMap]) -> None:
def test_send_requests(request_map_collection: List[RequestMap]) -> None:
session = Clump(requests=request_map_collection)
responses: list[RequestResponse] = session.sendRequests()
responses: List[RequestResponse] = session.sendRequests()
assert len(responses) == 100
for response in responses:
assert response.statusCode == 200
assert response.error is None


def test_send_requests_with_exceptions(
request_map_collection: list[RequestMap],
request_map_collection: List[RequestMap],
request_map_to_trigger_exception: RequestMap,
) -> None:
requests: list[RequestMap] = request_map_collection.copy()
requests: List[RequestMap] = request_map_collection.copy()
requests.append(request_map_to_trigger_exception)
session = Clump(requests=requests)
responses: list[RequestResponse] = session.sendRequests(return_exceptions=True)
responses: List[RequestResponse] = session.sendRequests(return_exceptions=True)
assert len(responses) == 101
for response in responses:
if response.requestMap.url == "http://localhost:44777/exception":
Expand Down

0 comments on commit 2c7a56f

Please sign in to comment.