Skip to content

Commit

Permalink
Merge pull request #141 from kloczek/develop
Browse files Browse the repository at this point in the history
really drop python<=3.8 support
  • Loading branch information
Colin-b authored Sep 19, 2024
2 parents 9e1661f + 8449b1b commit 042e9c3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ maintainers = [
]
keywords = [
"httpx",
"mock",
"pytest",
"testing",
]
Expand Down
4 changes: 2 additions & 2 deletions pytest_httpx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def assert_all_responses_were_requested() -> bool:


@pytest.fixture
def non_mocked_hosts() -> List[str]:
def non_mocked_hosts() -> list[str]:
return []


@pytest.fixture
def httpx_mock(
monkeypatch: MonkeyPatch,
assert_all_responses_were_requested: bool,
non_mocked_hosts: List[str],
non_mocked_hosts: list[str],
) -> Generator[HTTPXMock, None, None]:
# Ensure redirections to www hosts are handled transparently.
missing_www = [
Expand Down
16 changes: 6 additions & 10 deletions pytest_httpx/_httpx_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
from typing import (
Union,
Dict,
Sequence,
Tuple,
Iterable,
AsyncIterator,
Iterator,
Optional,
)
from collections.abc import Sequence, Iterable, AsyncIterator, Iterator

import httpcore
import httpx
Expand All @@ -19,19 +16,18 @@
# Those types are internally defined within httpx._types
HeaderTypes = Union[
httpx.Headers,
Dict[str, str],
Dict[bytes, bytes],
Sequence[Tuple[str, str]],
Sequence[Tuple[bytes, bytes]],
dict[str, str],
dict[bytes, bytes],
Sequence[tuple[str, str]],
Sequence[tuple[bytes, bytes]],
]


class IteratorStream(AsyncIteratorByteStream, IteratorByteStream):
def __init__(self, stream: Iterable[bytes]):
class Stream:
def __iter__(self) -> Iterator[bytes]:
for chunk in stream:
yield chunk
yield from stream

async def __aiter__(self) -> AsyncIterator[bytes]:
for chunk in stream:
Expand Down
3 changes: 2 additions & 1 deletion pytest_httpx/_httpx_mock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import inspect
from typing import Union, Optional, Callable, Any, Awaitable
from typing import Union, Optional, Callable, Any
from collections.abc import Awaitable

import httpx

Expand Down
6 changes: 2 additions & 4 deletions pytest_httpx/_pretty_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ def __init__(
self.request = request

headers_encoding = request.headers.encoding
self.expected_headers = set(
[
self.expected_headers = {
# httpx uses lower cased header names as internal key
header.lower().encode(headers_encoding)
for matcher in matchers
if matcher.headers
for header in matcher.headers
]
)
}
self.expect_body = any(
[
matcher.content is not None or matcher.json is not None
Expand Down
3 changes: 2 additions & 1 deletion pytest_httpx/_request_matcher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from typing import Optional, Union, Pattern, Any
from typing import Optional, Union, Any
from re import Pattern

import httpx

Expand Down

0 comments on commit 042e9c3

Please sign in to comment.