Add a `debug_mode`-state reversion test

pytest_pluginize
Tyler Goodlet 2025-05-07 15:06:44 -04:00
parent 06f7f2e06b
commit 2bb33da9c8
1 changed files with 23 additions and 0 deletions

View File

@ -83,3 +83,26 @@ def test_implicit_root_via_first_nursery(
assert tractor.current_actor().aid.name == 'root' assert tractor.current_actor().aid.name == 'root'
trio.run(main) 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)