home · contact · privacy
Move testing toml identification into detection of filename with same stem.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 28 Sep 2025 18:20:01 +0000 (20:20 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 28 Sep 2025 18:20:01 +0000 (20:20 +0200)
src/ircplom/testing.py
src/tests/config.toml [new file with mode: 0644]
src/tests/config.txt
src/tests/test.toml [deleted file]

index 831bbbfc903eae7c054b274670a5f233593e94e5..39ac913c1fedacca586b3ea1f4d5dc1c5a137486 100644 (file)
@@ -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/config.toml b/src/tests/config.toml
new file mode 100644 (file)
index 0000000..68c5c90
--- /dev/null
@@ -0,0 +1,11 @@
+[[server]]
+hostname = 'irc.test0.net'
+nickname = 'foo'
+password = 'bar'
+username = 'baz'
+realname = 'quux'
+port = 1234
+channels = [
+  '#test',
+  '##testtest',
+]
index 71037a39615baa9a643504ec315304c5c1030832..e56ed802784759585af200f30f8f1e817f499d63 100644 (file)
@@ -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: [#&]
diff --git a/src/tests/test.toml b/src/tests/test.toml
deleted file mode 100644 (file)
index 68c5c90..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[[server]]
-hostname = 'irc.test0.net'
-nickname = 'foo'
-password = 'bar'
-username = 'baz'
-realname = 'quux'
-port = 1234
-channels = [
-  '#test',
-  '##testtest',
-]