Download tests/test_runtime_hooks.py from build-small-hackathon/hackathon-advisor: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/build-small-hackathon/hackathon-advisor/resolve/main/tests/test_runtime_hooks.py
- Command line
-
hf download hf://spaces/build-small-hackathon/hackathon-advisor/tests/test_runtime_hooks.py
-
curl -L -o test_runtime_hooks.py https://huggingface.co/spaces/build-small-hackathon/hackathon-advisor/resolve/main/tests/test_runtime_hooks.py
1.02 kB
| from types import SimpleNamespace | |
| from hackathon_advisor.runtime_hooks import _is_asyncio_invalid_fd_cleanup | |
| def test_asyncio_invalid_fd_cleanup_hook_matches_only_event_loop_destructor() -> None: | |
| def event_loop_del() -> None: | |
| pass | |
| event_loop_del.__qualname__ = "BaseEventLoop.__del__" | |
| def other_function() -> None: | |
| pass | |
| assert _is_asyncio_invalid_fd_cleanup( | |
| SimpleNamespace( | |
| exc_type=ValueError, | |
| exc_value=ValueError("Invalid file descriptor: -1"), | |
| object=event_loop_del, | |
| ) | |
| ) | |
| assert not _is_asyncio_invalid_fd_cleanup( | |
| SimpleNamespace( | |
| exc_type=ValueError, | |
| exc_value=ValueError("Invalid file descriptor: -1"), | |
| object=other_function, | |
| ) | |
| ) | |
| assert not _is_asyncio_invalid_fd_cleanup( | |
| SimpleNamespace( | |
| exc_type=RuntimeError, | |
| exc_value=RuntimeError("Invalid file descriptor: -1"), | |
| object=event_loop_del, | |
| ) | |
| ) | |