import asyncio import unittest class TestCase(unittest.TestCase): def test_socket_pair_leak(self): async def main(): loop = asyncio.get_running_loop() try: await loop.subprocess_exec(asyncio.SubprocessProtocol, "non-exisiting-executable") except OSError: print("non-existing indeed") asyncio.run(main(), debug=True) unittest.main()