tmp_bind cleans up properly on exceptions.
(self, log)
| 89 | assert {"y": 23} == log._context._dict |
| 90 | |
| 91 | def test_bind_exc(self, log): |
| 92 | """ |
| 93 | tmp_bind cleans up properly on exceptions. |
| 94 | """ |
| 95 | log = log.bind(y=23) |
| 96 | |
| 97 | with ( # noqa: PT012 |
| 98 | pytest.raises(CustomError), |
| 99 | pytest.deprecated_call(), |
| 100 | tmp_bind(log, x=42, y="foo") as tmp_log, |
| 101 | ): |
| 102 | assert ( |
| 103 | {"y": "foo", "x": 42} |
| 104 | == tmp_log._context._dict |
| 105 | == log._context._dict |
| 106 | ) |
| 107 | raise CustomError |
| 108 | |
| 109 | assert {"y": 23} == log._context._dict |
| 110 | |
| 111 | def test_tmp_bind_lazy(self): |
| 112 | """ |