tests/ldap: check regex match return value

error[unresolved-attribute]: Attribute `group` is not defined on `None` in union `Match[str] | None`
   --> testScriptWithTypes:152:21
    |
152 |   ldap_table_path = re.match('.* =.*ldap:(.*)', conf).group(1)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
This commit is contained in:
Martin Weinelt
2026-05-21 17:28:36 +02:00
parent 86a2bb9afd
commit 10dce12f73
+4 -1
View File
@@ -198,7 +198,10 @@ in
# to the expected value. # to the expected value.
def test_lookup(postconf_cmdline, key, expected): def test_lookup(postconf_cmdline, key, expected):
conf = machine.succeed(postconf_cmdline).rstrip() conf = machine.succeed(postconf_cmdline).rstrip()
ldap_table_path = re.match('.* =.*ldap:(.*)', conf).group(1) ldap_table_path_match = re.match('.* =.*ldap:(.*)', conf)
if not ldap_table_path_match:
raise RuntimeError(f"Failed to match LDAP table in '{postconf_cmdline}' response")
ldap_table_path = ldap_table_path_match.group(1)
value = machine.succeed(f"postmap -q {key} ldap:{ldap_table_path}").rstrip() value = machine.succeed(f"postmap -q {key} ldap:{ldap_table_path}").rstrip()
try: try:
assert value == expected assert value == expected