From 10dce12f737c1d63d5decc4569873ff5892864c8 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 21 May 2026 17:28:36 +0200 Subject: [PATCH] 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) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | --- tests/ldap.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ldap.nix b/tests/ldap.nix index 5df5580..7a771ad 100644 --- a/tests/ldap.nix +++ b/tests/ldap.nix @@ -198,7 +198,10 @@ in # to the expected value. def test_lookup(postconf_cmdline, key, expected): 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() try: assert value == expected