import subprocess import sys test_code = ''' import asyncio class NonTrueAwaitable: def __init__(self, inner): self.inner = inner def __bool__(self) -> bool: return False def __await__(self): val = yield from self.inner return val async def run(): async def inner(): return 42 return await NonTrueAwaitable(inner()) print(asyncio.get_event_loop().run_until_complete(run())) ''' try: subprocess.check_call([sys.executable, '-c', test_code], env={}) except: print('failed without PYTHONASYNCIODEBUG') else: print('works without PYTHONASYNCIODEBUG') try: subprocess.check_call([sys.executable, '-c', test_code], env={'PYTHONASYNCIODEBUG': '1'}) except: print('failed with PYTHONASYNCIODEBUG') else: print('works with PYTHONASYNCIODEBUG')