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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.22
rev: v0.16.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -23,7 +23,7 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/pycqa/isort
rev: 9.0.0b1
rev: 9.0.0b5
hooks:
- id: isort
name: isort (python)
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ dev: .venv/.st-venv-completed
precommit: dev
poetry run pre-commit run -a

.PHONY: prek
prek: dev
poetry run prek run -a

.PHONY: mypy
mypy: dev
.venv/bin/mypy
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ lint.ignore = [
"C408",
"C901",
"COM812",
"CPY001",
"EM101",
"EM103",
"FBT002",
Expand Down Expand Up @@ -148,3 +149,6 @@ lint.ignore = [
line-length = 120
target-version = "py310"
exclude = ["doc", "example*.py", "tests/examples/*.py"]

[tool.ruff.lint.pylint]
max-positional-args = 10
2 changes: 1 addition & 1 deletion pytest_httpserver/blocking_httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def assert_request(
data: str | bytes | None = None,
data_encoding: str = "utf-8",
headers: Mapping[str, str] | None = None,
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None = None,
header_value_matcher: HeaderValueMatcher | None = None,
json: Any = UNDEFINED,
timeout: int = 30,
Expand Down
12 changes: 6 additions & 6 deletions pytest_httpserver/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def get_comparing_values(self, request_query_string: bytes) -> tuple[bool, bool]
return (True, False)


def _create_query_matcher(query_string: None | QueryMatcher | str | bytes | Mapping[str, str]) -> QueryMatcher:
def _create_query_matcher(query_string: QueryMatcher | str | bytes | Mapping[str, str] | None) -> QueryMatcher:
if isinstance(query_string, QueryMatcher):
return query_string

Expand Down Expand Up @@ -300,7 +300,7 @@ class RequestMatcherKwargs(TypedDict, total=False):
data: str | bytes | None
data_encoding: str
headers: Mapping[str, str] | None
query_string: None | QueryMatcher | str | bytes | Mapping[str, str]
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None
header_value_matcher: HVMATCHER_T | None
json: Any

Expand Down Expand Up @@ -341,7 +341,7 @@ def __init__(
data: str | bytes | None = None,
data_encoding: str = "utf-8",
headers: Mapping[str, str] | None = None,
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None = None,
header_value_matcher: HVMATCHER_T | None = None,
json: Any = UNDEFINED,
) -> None:
Expand Down Expand Up @@ -1068,7 +1068,7 @@ def expect_request(
data: str | bytes | None = None,
data_encoding: str = "utf-8",
headers: Mapping[str, str] | None = None,
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None = None,
header_value_matcher: HVMATCHER_T | None = None,
handler_type: HandlerType = HandlerType.PERMANENT,
json: Any = UNDEFINED,
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def expect_oneshot_request(
data: str | bytes | None = None,
data_encoding: str = "utf-8",
headers: Mapping[str, str] | None = None,
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None = None,
header_value_matcher: HVMATCHER_T | None = None,
json: Any = UNDEFINED,
) -> RequestHandler:
Expand Down Expand Up @@ -1206,7 +1206,7 @@ def expect_ordered_request(
data: str | bytes | None = None,
data_encoding: str = "utf-8",
headers: Mapping[str, str] | None = None,
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
query_string: QueryMatcher | str | bytes | Mapping[str, str] | None = None,
header_value_matcher: HVMATCHER_T | None = None,
json: Any = UNDEFINED,
) -> RequestHandler:
Expand Down
12 changes: 8 additions & 4 deletions tests/test_log_querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def test_verify_assert_msg(httpserver: HTTPServer):

expected_lines = [
"Matching request found 0 times but expected 1 times.",
"Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
"=None json={'foo': 'bar'}>",
(
"Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
"=None json={'foo': 'bar'}>"
),
"Found 1 similar request(s):",
"--- Similar Request Start",
"Path: /foo",
Expand Down Expand Up @@ -70,8 +72,10 @@ def test_verify_assert_msg_no_similar_requests(httpserver: HTTPServer):

expected_lines = [
"Matching request found 0 times but expected 1 times.",
"Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
"=None json={'foo': 'bar'}>",
(
"Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
"=None json={'foo': 'bar'}>"
),
"No similar requests found.",
]

Expand Down
Loading