summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2023-11-06 17:57:28 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2023-11-07 09:58:39 +0100
commit85bcf2d99ffc5563193963ed2f4b464b3fd071be (patch)
tree9a44dff75487159fd6cc9ede7cad8f367d7a862c
parentf6998c8daa2df26f3ddfe6af2f16164f97f3017e (diff)
test-client: fix warnings about invalid escape sequencesbg/python-escape-seq
In Python 3.12 a backslash-character pair that is not a valid escape sequence generates a SyntaxWarning [1]: src/tests/client/test-client.py:2161: SyntaxWarning: invalid escape sequence '\?' nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]") Use raw strings to avoid that. [1] https://docs.python.org/3/whatsnew/3.12.html https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1785
-rwxr-xr-xsrc/tests/client/test-client.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py
index e313a7d63a..8b9cdb0d22 100755
--- a/src/tests/client/test-client.py
+++ b/src/tests/client/test-client.py
@@ -544,7 +544,7 @@ class Util:
[
"sed",
"-e",
- "/^--[0-9]\+-- WARNING: unhandled .* syscall: /,/^--[0-9]\+-- it at http.*\.$/d",
+ r"/^--[0-9]\+-- WARNING: unhandled .* syscall: /,/^--[0-9]\+-- it at http.*\.$/d",
name,
],
stdout=subprocess.PIPE,
@@ -2158,18 +2158,18 @@ class TestNmcli(unittest.TestCase):
nmc.pexp.expect("Interface name:")
nmc.pexp.sendline("eth0")
nmc.pexp.expect("There are 3 optional settings for Wired Ethernet.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 2 optional settings for IPv4 protocol.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 2 optional settings for IPv6 protocol.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 4 optional settings for Proxy.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
- nmc.pexp.expect("Connection 'ethernet' \(.*\) successfully added.")
+ nmc.pexp.expect(r"Connection 'ethernet' \(.*\) successfully added.")
nmc.pexp.expect(pexpect.EOF)
Util.valgrind_check_log(nmc.valgrind_log, "test_ask_mode")
@@ -2190,34 +2190,34 @@ class TestNmcli(unittest.TestCase):
nmc.pexp.expect("Interface name:")
nmc.pexp.sendline("eth0")
nmc.pexp.expect("There are 3 optional settings for Wired Ethernet.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 2 optional settings for IPv4 protocol.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 2 optional settings for IPv6 protocol.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect("There are 4 optional settings for Proxy.")
- nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")
+ nmc.pexp.expect(r"Do you want to provide them\? \(yes/no\) \[yes]")
nmc.pexp.sendline("no")
nmc.pexp.expect(
- "\[connection\]\r\n"
- + "id=ethernet\r\n"
- + "uuid=.*\r\n"
- + "type=ethernet\r\n"
- + "interface-name=eth0\r\n"
- + "\r\n"
- + "\[ethernet\]\r\n"
- + "\r\n"
- + "\[ipv4\]\r\n"
- + "method=auto\r\n"
- + "\r\n"
- + "\[ipv6\]\r\n"
- + "addr-gen-mode=default\r\n"
- + "method=auto\r\n"
- + "\r\n"
- + "\[proxy\]\r\n"
+ r"\[connection\]\r\n"
+ r"id=ethernet\r\n"
+ r"uuid=.*\r\n"
+ r"type=ethernet\r\n"
+ r"interface-name=eth0\r\n"
+ r"\r\n"
+ r"\[ethernet\]\r\n"
+ r"\r\n"
+ r"\[ipv4\]\r\n"
+ r"method=auto\r\n"
+ r"\r\n"
+ r"\[ipv6\]\r\n"
+ r"addr-gen-mode=default\r\n"
+ r"method=auto\r\n"
+ r"\r\n"
+ r"\[proxy\]\r\n"
)
nmc.pexp.expect(pexpect.EOF)
Util.valgrind_check_log(nmc.valgrind_log, "test_ask_offline")
@@ -2512,12 +2512,12 @@ class TestNmCloudSetup(unittest.TestCase):
nmc.pexp.expect("provider azure detected")
nmc.pexp.expect("found interfaces: CC:00:00:00:00:01, CC:00:00:00:00:02")
nmc.pexp.expect("found azure interfaces: 2")
- nmc.pexp.expect("interface\[0]: found a matching device with hwaddr")
+ nmc.pexp.expect(r"interface\[0]: found a matching device with hwaddr")
nmc.pexp.expect(
- "interface\[0]: (received subnet address|received subnet prefix 20)"
+ r"interface\[0]: (received subnet address|received subnet prefix 20)"
)
nmc.pexp.expect(
- "interface\[0]: (received subnet address|received subnet prefix 20)"
+ r"interface\[0]: (received subnet address|received subnet prefix 20)"
)
nmc.pexp.expect("get-config: success")
nmc.pexp.expect("meta data received")
@@ -2648,7 +2648,7 @@ class TestNmCloudSetup(unittest.TestCase):
nmc.pexp.expect("provider GCP detected")
nmc.pexp.expect("found interfaces: CC:00:00:00:00:01, CC:00:00:00:00:02")
nmc.pexp.expect("found GCP interfaces: 2")
- nmc.pexp.expect("GCP interface\[0]: found a requested device with hwaddr")
+ nmc.pexp.expect(r"GCP interface\[0]: found a requested device with hwaddr")
nmc.pexp.expect("get-config: success")
nmc.pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified