Use as a context manager to check that the code inside the ``with`` block either exits with an exception or executes at least one :ref:`checkpoint `. Raises: AssertionError: if no checkpoint was executed. Example: Check that :func:`trio.sleep` is a checkpoi
()
| 30 | |
| 31 | |
| 32 | def assert_checkpoints() -> AbstractContextManager[None]: |
| 33 | """Use as a context manager to check that the code inside the ``with`` |
| 34 | block either exits with an exception or executes at least one |
| 35 | :ref:`checkpoint <checkpoints>`. |
| 36 | |
| 37 | Raises: |
| 38 | AssertionError: if no checkpoint was executed. |
| 39 | |
| 40 | Example: |
| 41 | Check that :func:`trio.sleep` is a checkpoint, even if it doesn't |
| 42 | block:: |
| 43 | |
| 44 | with trio.testing.assert_checkpoints(): |
| 45 | await trio.sleep(0) |
| 46 | |
| 47 | """ |
| 48 | __tracebackhide__ = True |
| 49 | return _assert_yields_or_not(True) |
| 50 | |
| 51 | |
| 52 | def assert_no_checkpoints() -> AbstractContextManager[None]: |
searching dependent graphs…