From ba5b174f58de2f651934aec4c4b2deaa67889c8a Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 28 Sep 2025 20:20:01 +0200 Subject: [PATCH] Move testing toml identification into detection of filename with same stem. --- src/ircplom/testing.py | 16 ++++++---------- src/tests/{test.toml => config.toml} | 0 src/tests/config.txt | 3 +-- 3 files changed, 7 insertions(+), 12 deletions(-) rename src/tests/{test.toml => config.toml} (100%) diff --git a/src/ircplom/testing.py b/src/ircplom/testing.py index 831bbbf..39ac913 100644 --- a/src/ircplom/testing.py +++ b/src/ircplom/testing.py @@ -169,28 +169,24 @@ class _Playbook: return None return tuple(line.split(' ', maxsplit=1)) - def check_start_for_config(self) -> Optional[Path]: - 'While on first line, if config file identified, inc idx, return path.' - assert self._idx == 0 - if self._lines[self._idx].startswith('#config '): - _, toml_name = self._lines[0].split(maxsplit=1) - self._idx += 1 - return PATH_TESTS.joinpath(toml_name) - return None - class TestingClientTui(ClientTui): 'Collects keypresses via TestTerminal and test file, compares log results.' _client_cls = _TestClientKnowingTui _clients: list[_TestClientKnowingTui] + _path_config: Optional[Path] = None _path_logs = None _path_test: Path def __init__(self, **kwargs) -> None: + fname_config = self._path_test.stem + '.toml' + path_config = PATH_TESTS.joinpath(fname_config) + if path_config.exists(): + assert path_config.is_file() + self._path_config = path_config self._clients = [] self._playbook = _Playbook(path=self._path_test, get_client=lambda idx: self._clients[idx]) - self._path_config = self._playbook.check_start_for_config() super().__init__(**kwargs) assert isinstance(self._term, TestTerminal) self._playbook.put_keypress = self._term._q_keypresses.put diff --git a/src/tests/test.toml b/src/tests/config.toml similarity index 100% rename from src/tests/test.toml rename to src/tests/config.toml diff --git a/src/tests/config.txt b/src/tests/config.txt index 71037a3..e56ed80 100644 --- a/src/tests/config.txt +++ b/src/tests/config.txt @@ -1,5 +1,4 @@ -#config test.toml -0 # Found config at tests/test.toml, reading … +0 # Found config at tests/config.toml, reading … 0 # Connecting: {'hostname': 'irc.test0.net', 'nickname': 'foo', 'password': 'bar', 'username': 'baz', 'realname': 'quux', 'port': 1234, 'channels': ['#test', '##testtest']} 1 $ isupport cleared 1 $ isupport:CHANTYPES set to: [#&] -- 2.30.2