testing/plugins_integration/pytest_twisted_integration.py
raw| 1 | # mypy: allow-untyped-defs |
| 2 | from __future__ import annotations |
| 3 | |
| 4 | import pytest_twisted |
| 5 | from twisted.internet.task import deferLater |
| 6 | |
| 7 | |
| 8 | def sleep(): |
| 9 | import twisted.internet.reactor |
| 10 | |
| 11 | return deferLater(clock=twisted.internet.reactor, delay=0) |
| 12 | |
| 13 | |
| 14 | @pytest_twisted.inlineCallbacks |
| 15 | def test_inlineCallbacks(): |
| 16 | yield sleep() |
| 17 | |
| 18 | |
| 19 | @pytest_twisted.ensureDeferred |
| 20 | async def test_inlineCallbacks_async(): |
| 21 | await sleep() |