diff --git a/tests/test_root_runtime.py b/tests/test_root_runtime.py index c97d4eba..6fc39b7d 100644 --- a/tests/test_root_runtime.py +++ b/tests/test_root_runtime.py @@ -83,3 +83,26 @@ def test_implicit_root_via_first_nursery( assert tractor.current_actor().aid.name == 'root' trio.run(main) + + +def test_runtime_vars_unset( + reg_addr: tuple, + debug_mode: bool +): + ''' + Ensure any `._state._runtime_vars` are restored to default values + after the root actor-runtime exits! + + ''' + assert not tractor._state._runtime_vars['_debug_mode'] + async def main(): + assert not tractor._state._runtime_vars['_debug_mode'] + async with tractor.open_nursery( + debug_mode=True, + ): + assert tractor._state._runtime_vars['_debug_mode'] + + # after runtime closure, should be reverted! + assert not tractor._state._runtime_vars['_debug_mode'] + + trio.run(main)