()
| 181 | def test_eval_exceptions_preserve_promise_rejection(): |
| 182 | # Tests for https://github.com/Distributive-Network/PythonMonkey/blob/d9a8ebe/src/PromiseType.cc#L46-L48 |
| 183 | async def async_fn(): |
| 184 | try: |
| 185 | await pm.eval("Promise.reject(Number(123))", {'mutedErrors': True}) |
| 186 | # The mutedErrors option is required to avoid sending this to uncaughtExceptionHandler prematurely |
| 187 | except Exception as py_err: |
| 188 | assert type(py_err) is pm.SpiderMonkeyError |
| 189 | assert repr(py_err) == "SpiderMonkeyError(123.0)" |
| 190 | assert pm.eval("(e) => e instanceof Number")(py_err) |
| 191 | assert pm.eval("(e) => e == 123")(py_err) |
| 192 | try: |
| 193 | await pm.eval("Promise.reject(new TypeError('Promise rejection'))", {'mutedErrors': True}) |
| 194 | except Exception as py_err: |
| 195 | assert type(py_err) is pm.SpiderMonkeyError |
| 196 | assert pm.eval("(e) => e instanceof TypeError")(py_err) |
| 197 | assert pm.eval("(e) => e.message == 'Promise rejection'")(py_err) |
| 198 | return True |
| 199 | assert asyncio.run(async_fn()) |
| 200 | |
| 201 |
no outgoing calls
no test coverage detected