Functions
assert_is_fragment
2
None
▼
Assert the response is a fragment (has content, no full page wrapper).
Checks …
assert_is_fragment
2
None
▼
def assert_is_fragment(response: Response, *, status: int = 200) -> None
Assert the response is a fragment (has content, no full page wrapper).
Checks that the response has the expected status and does not
contain<html> / </html>tags that indicate a full page.
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
status |
int |
Default:200
|
assert_fragment_contains
2
None
▼
Assert the fragment response body contains the given text.
assert_fragment_contains
2
None
▼
def assert_fragment_contains(response: Response, text: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
text |
str |
assert_fragment_not_contains
2
None
▼
Assert the fragment response body does **not** contain the given text.
assert_fragment_not_contains
2
None
▼
def assert_fragment_not_contains(response: Response, text: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
text |
str |
assert_is_error_fragment
2
None
▼
Assert the response is a chirp error fragment snippet.
Error fragments contain…
assert_is_error_fragment
2
None
▼
def assert_is_error_fragment(response: Response, *, status: int | None = None) -> None
Assert the response is a chirp error fragment snippet.
Error fragments contain thechirp-error CSS class and a data-status
attribute matching the HTTP status code.
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
status |
int | None |
Default:None
|
hx_headers
1
dict[str, str]
▼
Extract all HX-* response headers into a dict.
Keys are normalized to canonica…
hx_headers
1
dict[str, str]
▼
def hx_headers(response: Response) -> dict[str, str]
Extract all HX-* response headers into a dict.
Keys are normalized to canonical htmx casing (e.g.HX-Push-Url)
regardless of whether the response went through the ASGI sender
(which lowercases header names per the HTTP spec).
Useful for quick inspection in tests::
headers = hx_headers(response)
assert headers["HX-Redirect"] == "/dashboard"
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
Returns
dict[str, str]
assert_hx_redirect
2
None
▼
Assert the response contains an ``HX-Redirect`` header with the given URL.
assert_hx_redirect
2
None
▼
def assert_hx_redirect(response: Response, url: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
url |
str |
assert_hx_trigger
3
None
▼
Assert the response triggers an htmx client-side event.
assert_hx_trigger
3
None
▼
def assert_hx_trigger(response: Response, event: str | dict[str, Any], *, after: str | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
The HTTP response to check. |
event |
str | dict[str, Any] |
The event name (string) or event dict to match. |
after |
str | None |
If None
|
assert_hx_retarget
2
None
▼
Assert the response contains an ``HX-Retarget`` header.
assert_hx_retarget
2
None
▼
def assert_hx_retarget(response: Response, selector: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
selector |
str |
assert_hx_reswap
2
None
▼
Assert the response contains an ``HX-Reswap`` header.
assert_hx_reswap
2
None
▼
def assert_hx_reswap(response: Response, strategy: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
strategy |
str |
assert_hx_push_url
2
None
▼
Assert the response contains an ``HX-Push-Url`` header.
assert_hx_push_url
2
None
▼
def assert_hx_push_url(response: Response, url: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
response |
Response |
|
url |
str |