(seconds: float, cleanup: Any = None)
| 521 | |
| 522 | @contextlib.contextmanager |
| 523 | def skip_if_timeout(seconds: float, cleanup: Any = None): |
| 524 | |
| 525 | now = time.time() |
| 526 | yield |
| 527 | sec = time.time() - now |
| 528 | if sec > seconds: |
| 529 | try: |
| 530 | cleanup() |
| 531 | finally: |
| 532 | config.skip_test( |
| 533 | f"test took too long ({sec:.4f} seconds > {seconds})" |
| 534 | ) |