| 1041 | ) |
| 1042 | |
| 1043 | async def to_be_ok( |
| 1044 | self, |
| 1045 | ) -> None: |
| 1046 | __tracebackhide__ = True |
| 1047 | if self._is_not is not self._actual.ok: |
| 1048 | return |
| 1049 | message = f"Response status expected to be within [200..299] range, was '{self._actual.status}'" |
| 1050 | if self._is_not: |
| 1051 | message = message.replace("expected to", "expected not to") |
| 1052 | out_message = self._custom_message or message |
| 1053 | out_message += format_call_log(await self._actual._fetch_log()) |
| 1054 | |
| 1055 | content_type = self._actual.headers.get("content-type") |
| 1056 | is_text_encoding = content_type and is_textual_mime_type(content_type) |
| 1057 | text = await self._actual.text() if is_text_encoding else None |
| 1058 | if text is not None: |
| 1059 | out_message += f"\n Response Text:\n{text[:1000]}" |
| 1060 | |
| 1061 | _record_soft_or_raise(AssertionError(out_message), self._is_soft) |
| 1062 | |
| 1063 | async def not_to_be_ok(self) -> None: |
| 1064 | __tracebackhide__ = True |