''' `tractor.devx.*` tooling sub-pkg test space. ''' from __future__ import annotations import platform import signal import time from typing import ( Callable, TYPE_CHECKING, ) import pytest from pexpect.exceptions import ( TIMEOUT, ) from pexpect.spawnbase import SpawnBase from tractor._testing import ( mk_cmd, ) from tractor.devx.debug import ( _pause_msg as _pause_msg, _crash_msg as _crash_msg, _repl_fail_msg as _repl_fail_msg, _ctlc_ignore_header as _ctlc_ignore_header, ) from ..conftest import ( _ci_env, ) if TYPE_CHECKING: from pexpect import pty_spawn _non_linux: bool = platform.system() != 'Linux' def pytest_configure(config): # register custom marks to avoid warnings see, # https://docs.pytest.org/en/stable/how-to/writing_plugins.html#registering-custom-markers config.addinivalue_line( 'markers', 'ctlcs_bish: test will (likely) not behave under SIGINT..' ) # a fn that sub-instantiates a `pexpect.spawn()` # and returns it. type PexpectSpawner = Callable[ [str], pty_spawn.spawn, ] @pytest.fixture def spawn( start_method: str, testdir: pytest.Pytester, reg_addr: tuple[str, int], ) -> PexpectSpawner: ''' Use the `pexpect` module shipped via `testdir.spawn()` to run an `./examples/..` script by name. ''' supported_spawners: set[str] = { 'trio', # ?TODO, other spawners that will work? # - [ ] need to pass `start_method={spawner}` to underlying # `examples/debugging/