From fc2e298a29d95189e4fe5d82560211f725efc6e2 Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 30 Apr 2026 20:54:50 -0400 Subject: [PATCH] Update `sync_bp` + tighten `test_pause_from_sync` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `disable_pdbp_color()` to the `sync_bp` example to suppress pygments prompt coloring when `PYTHON_COLORS=0` — makes pexpect pattern matching deterministic. Deats, - set `loglevel='pdb'` in both script + test spawn. - disable `enable_stack_on_sig` in example, assert no `stackscope` output in test. - update `attach_patts` keys/values with `|_ None: + disable_pdbp_color() async with ( tractor.open_nursery( debug_mode=True, maybe_enable_greenback=True, - enable_stack_on_sig=True, - # loglevel='warning', - # loglevel='devx', + + # XXX flags required for test pattern matching. + loglevel='pdb', + # enable_stack_on_sig=True, ) as an, trio.open_nursery() as tn, ): @@ -68,8 +84,8 @@ async def main() -> None: p: tractor.Portal = await an.start_actor( 'subactor', enable_modules=[__name__], - # infect_asyncio=True, debug_mode=True, + # infect_asyncio=True, ) # TODO: 3 sub-actor usage cases: diff --git a/tests/devx/conftest.py b/tests/devx/conftest.py index 12e3ce04..2c621f41 100644 --- a/tests/devx/conftest.py +++ b/tests/devx/conftest.py @@ -95,6 +95,8 @@ def spawn( os.environ['PYTHON_COLORS'] = '0' # disable all ANSI color output # os.environ['NO_COLOR'] = '1' + # ?TODO, doesn't seem to disable prompt color + # for `pdbp`? def set_spawn_method( start_method: str, diff --git a/tests/devx/test_pause_from_non_trio.py b/tests/devx/test_pause_from_non_trio.py index 2288653f..0710ba80 100644 --- a/tests/devx/test_pause_from_non_trio.py +++ b/tests/devx/test_pause_from_non_trio.py @@ -66,19 +66,28 @@ def test_pause_from_sync( # XXX required for `breakpoint()` overload and # thus`tractor.devx.pause_from_sync()`. pytest.importorskip('greenback') - child = spawn('sync_bp') + child = spawn( + 'sync_bp', + loglevel='pdb', # XXX pattern matching + ) # first `sync_pause()` after nurseries open child.expect(PROMPT) - assert_before( + _before: str = assert_before( child, [ - # pre-prompt line - _pause_msg, - "\n\n' + ')>\n' ) @classmethod @@ -282,7 +282,7 @@ class Lock: ): message += ( '-> No new task holds the TTY lock!\n\n' - f'{Lock.repr()}\n' + f'{Lock.repr()}' ) elif (