(
self,
expression: str,
expect_options: FrameExpectOptions,
expected: Any,
message: str,
title: str = None,
)
| 85 | ) |
| 86 | |
| 87 | async def _expect_impl( |
| 88 | self, |
| 89 | expression: str, |
| 90 | expect_options: FrameExpectOptions, |
| 91 | expected: Any, |
| 92 | message: str, |
| 93 | title: str = None, |
| 94 | ) -> None: |
| 95 | __tracebackhide__ = True |
| 96 | expect_options["isNot"] = self._is_not |
| 97 | if expect_options.get("timeout") is None: |
| 98 | expect_options["timeout"] = self._timeout or 5_000 |
| 99 | if expect_options["isNot"]: |
| 100 | message = message.replace("expected to", "expected not to") |
| 101 | if "useInnerText" in expect_options and expect_options["useInnerText"] is None: |
| 102 | del expect_options["useInnerText"] |
| 103 | result = await self._call_expect(expression, expect_options, title) |
| 104 | if result["matches"] == self._is_not: |
| 105 | received = result.get("received") or {} |
| 106 | aria_snapshot = None |
| 107 | if isinstance(received, dict): |
| 108 | aria_snapshot = received.get("ariaSnapshot") |
| 109 | value = received.get("value") |
| 110 | actual = parse_value(value) if value is not None else None |
| 111 | else: |
| 112 | actual = received |
| 113 | if self._custom_message: |
| 114 | out_message = self._custom_message |
| 115 | if expected is not None: |
| 116 | out_message += f"\nExpected value: '{expected or '<None>'}'" |
| 117 | else: |
| 118 | out_message = ( |
| 119 | f"{message} '{expected}'" if expected is not None else f"{message}" |
| 120 | ) |
| 121 | error_message = result.get("errorMessage") |
| 122 | error_message = f"\n{error_message}" if error_message else "" |
| 123 | aria_snapshot_message = ( |
| 124 | f"\nAria snapshot:\n{aria_snapshot}" if aria_snapshot else "" |
| 125 | ) |
| 126 | _record_soft_or_raise( |
| 127 | AssertionError( |
| 128 | f"{out_message}\nActual value: {actual}{error_message} {format_call_log(result.get('log'))}{aria_snapshot_message}" |
| 129 | ), |
| 130 | self._is_soft, |
| 131 | ) |
| 132 | |
| 133 | |
| 134 | class PageAssertions(AssertionsBase): |
no test coverage detected