Commit 220526d127 for bind

commit 220526d127de744f92f4ce4879f5c62834fcb2dc
Author: Michal Nowak <mnowak@isc.org>
Date:   Fri Oct 9 15:49:02 2026 +0000

    Bind matches and lookups in their conditions

    Python 3.8 added assignment expressions, which the system tests already
    use elsewhere.  Use them for the match-then-test pairs in isctest's
    kasp, text, watchlog and OpenSSL-config modules, for the finished-line
    loop in isctest.text, for the executable lookups in the doth fixtures
    and for the asyncserver's TCP read loop.

    Assisted-by: Claude:claude-opus-5-5

diff --git a/bin/tests/system/doth/conftest.py b/bin/tests/system/doth/conftest.py
index 633c98f97b..5f335db5f5 100644
--- a/bin/tests/system/doth/conftest.py
+++ b/bin/tests/system/doth/conftest.py
@@ -19,8 +19,7 @@ import isctest
 @pytest.fixture
 def gnutls_cli_executable():
     # Ensure gnutls-cli is available.
-    executable = shutil.which("gnutls-cli")
-    if not executable:
+    if not (executable := shutil.which("gnutls-cli")):
         pytest.skip("gnutls-cli not found in PATH")

     # Ensure gnutls-cli supports the --logfile command-line option.
@@ -36,8 +35,7 @@ def gnutls_cli_executable():
 @pytest.fixture
 def sslyze_executable():
     # Check whether sslyze is available.
-    executable = shutil.which("sslyze")
-    if not executable:
+    if not (executable := shutil.which("sslyze")):
         pytest.skip("sslyze not found in PATH")

     return executable
diff --git a/bin/tests/system/isctest/asyncserver/__init__.py b/bin/tests/system/isctest/asyncserver/__init__.py
index 49eb2d3a77..50bc49f647 100644
--- a/bin/tests/system/isctest/asyncserver/__init__.py
+++ b/bin/tests/system/isctest/asyncserver/__init__.py
@@ -585,10 +585,7 @@ class AsyncDnsServer(_AsyncServer):
         try:
             if self._connection_handler:
                 await self._connection_handler.handle(reader, writer, peer)
-            while True:
-                wire = await self._read_tcp_query(reader, peer)
-                if not wire:
-                    break
+            while wire := await self._read_tcp_query(reader, peer):
                 await self._send_tcp_response(writer, peer, wire)
         except _ConnectionTeardownRequested:
             pass
diff --git a/bin/tests/system/isctest/kasp.py b/bin/tests/system/isctest/kasp.py
index 0003a324c0..0837d09df9 100644
--- a/bin/tests/system/isctest/kasp.py
+++ b/bin/tests/system/isctest/kasp.py
@@ -401,8 +401,7 @@ class Key(FileZoneKey):
         regex = rf";\s+{metadata}:\s+(\d+).*"
         with open(self.keyfile, "r", encoding="utf-8") as file:
             for line in file:
-                match = re.match(regex, line)
-                if match is not None:
+                if match := re.match(regex, line):
                     try:
                         return KeyTimingMetadata(match.group(1))
                     except ValueError:
@@ -425,8 +424,7 @@ class Key(FileZoneKey):
             regex = rf";\s+{metadata}:\s+(\S+).*"
         with open(file, "r", encoding="utf-8") as fp:
             for line in fp:
-                match = re.match(regex, line)
-                if match is not None:
+                if match := re.match(regex, line):
                     value = match.group(1)
                     break
         if must_exist and value == "undefined":
@@ -1564,8 +1562,7 @@ def next_key_event_equals(server, zone, next_event):
     maxval = val + NEXT_KEY_EVENT_THRESHOLD
     with open(f"{server.identifier}/named.run", "r", encoding="utf-8") as fp:
         for line in fp:
-            match = re.match(waitfor, line)
-            if match is not None:
+            if match := re.match(waitfor, line):
                 nextval = int(match.group(1))
                 if minval <= nextval <= maxval:
                     next_found = True
@@ -1594,14 +1591,12 @@ def keydir_to_keylist(
     if keydir is None:
         regex = rf"(K{zname}\.\+.*\+.*)\.key"
         for filename in glob.glob(f"K{zname}.+*+*.key"):
-            match = re.match(regex, filename)
-            if match is not None:
+            if match := re.match(regex, filename):
                 all_keys.append(Key(match.group(1)))
     else:
         regex = rf"{keydir}/(K{zname}\.\+.*\+.*)\.key"
         for filename in glob.glob(f"{keydir}/K{zname}.+*+*.key"):
-            match = re.match(regex, filename)
-            if match is not None:
+            if match := re.match(regex, filename):
                 all_keys.append(Key(match.group(1), keydir))

     states = ["GoalState", "DNSKEYState", "KRRSIGState", "ZRRSIGState", "DSState"]
diff --git a/bin/tests/system/isctest/log/watchlog.py b/bin/tests/system/isctest/log/watchlog.py
index 71282ad062..643950b516 100644
--- a/bin/tests/system/isctest/log/watchlog.py
+++ b/bin/tests/system/isctest/log/watchlog.py
@@ -99,8 +99,7 @@ class WatchLog(abc.ABC):
         while time.monotonic() < self._deadline:
             for line in self._reader.readlines():
                 for regex in regexes:
-                    match = regex.search(line)
-                    if match:
+                    if match := regex.search(line):
                         return match
             time.sleep(0.1)
         raise WatchLogTimeout(
diff --git a/bin/tests/system/isctest/text.py b/bin/tests/system/isctest/text.py
index 67a56c4afc..96f548c98c 100644
--- a/bin/tests/system/isctest/text.py
+++ b/bin/tests/system/isctest/text.py
@@ -44,8 +44,7 @@ class Grep(abc.ABC):
         regex = compile_pattern(pattern)

         for line in self.readlines():
-            match = regex.search(line)
-            if match:
+            if match := regex.search(line):
                 yield match

     def grep(self, pattern: FlexPattern) -> list[Match]:
@@ -171,8 +170,5 @@ class LineReader(Grep):
         """
         Wrapper around io.readline() which only returns finished lines.
         """
-        while True:
-            line = self.readline()
-            if line is None:
-                return
+        while (line := self.readline()) is not None:
             yield line
diff --git a/bin/tests/system/isctest/vars/openssl.py b/bin/tests/system/isctest/vars/openssl.py
index a07efb0225..9c9adaa213 100644
--- a/bin/tests/system/isctest/vars/openssl.py
+++ b/bin/tests/system/isctest/vars/openssl.py
@@ -33,8 +33,7 @@ def parse_openssl_config(path: str | None):
     log.debug(f"parsing openssl config: {path}")
     with open(path, "r", encoding="utf-8") as conf:
         for line in conf:
-            res = regex.match(line)
-            if res:
+            if res := regex.match(line):
                 key = res.group(1).strip()
                 val = res.group(2).strip()
                 if key in ["MODULE_PATH", "pkcs11-module-path"]: