From: Frantisek Sumsal Date: Thu, 3 Feb 2022 17:55:12 +0000 (+0100) Subject: test-network: use raw strings for regexes with backslashes X-Git-Tag: v251-rc1~356^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=283863a1165eefddec2849fa51e7764291c65894;p=thirdparty%2Fsystemd.git test-network: use raw strings for regexes with backslashes It currently works because `\(` and `\)` are not valid escape sequences, so they're not treated differently. Using raw strings (or double backslashes) is a more correct solution. --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7c40707b18e..01003d2f05c 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -4255,7 +4255,7 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env) print(output) - self.assertRegex(output, 'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') + self.assertRegex(output, r'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') self.assertIn('Gateway: 192.168.5.3', output) self.assertRegex(output, 'DNS: 192.168.5.1\n *192.168.5.10') self.assertRegex(output, 'NTP: 192.168.5.1\n *192.168.5.11') @@ -4268,7 +4268,7 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env) print(output) - self.assertRegex(output, 'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') + self.assertRegex(output, r'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') self.assertIn('Gateway: 192.168.5.3', output) self.assertIn('DNS: 192.168.5.1', output) self.assertIn('NTP: 192.168.5.1', output) @@ -4280,7 +4280,7 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env) print(output) - self.assertRegex(output, 'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') + self.assertRegex(output, r'Address: 192.168.5.[0-9]* \(DHCP4 via 192.168.5.1\)') self.assertIn('Gateway: 192.168.5.1', output) self.assertIn('Time Zone: Europe/Berlin', output) @@ -4327,7 +4327,7 @@ class NetworkdDHCPServerRelayAgentTests(unittest.TestCase, Utilities): output = check_output(*networkctl_cmd, '-n', '0', 'status', 'client', env=env) print(output) - self.assertRegex(output, 'Address: 192.168.5.150 \(DHCP4 via 192.168.5.1\)') + self.assertRegex(output, r'Address: 192.168.5.150 \(DHCP4 via 192.168.5.1\)') class NetworkdDHCPClientTests(unittest.TestCase, Utilities): links = [