(seconds: float, cleanup: Any = None)
| 562 | |
| 563 | @contextlib.contextmanager |
| 564 | def skip_if_timeout(seconds: float, cleanup: Any = None): |
| 565 | |
| 566 | now = time.time() |
| 567 | yield |
| 568 | sec = time.time() - now |
| 569 | if sec > seconds: |
| 570 | try: |
| 571 | cleanup() |
| 572 | finally: |
| 573 | config.skip_test( |
| 574 | f"test took too long ({sec:.4f} seconds > {seconds})" |
| 575 | ) |