From f732316cf53543f7226c4723da875dcc1b305509 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 7 Aug 2023 13:49:33 +0200 Subject: [PATCH 1/2] integration-test: Fix invalid escaping Python 3.12 complains: integration-test:401: SyntaxWarning: invalid escape sequence '\$' subst_re = re.compile('\${([a-zA-Z_]+)}') integration-test:1047: SyntaxWarning: invalid escape sequence '\m' l = 'n"a\m\\"e' + fs_type integration-test:1053: SyntaxWarning: invalid escape sequence '\m' l = 'n"a\m\\"exft' --- src/tests/integration-test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/integration-test b/src/tests/integration-test index 4e7aa2699..8d7ffcf9d 100755 --- a/src/tests/integration-test +++ b/src/tests/integration-test @@ -387,7 +387,7 @@ class UDisksTestCase(unittest.TestCase): # read make variables make_vars = {} - var_re = re.compile('^([a-zA-Z_]+) = (.*)$') + var_re = re.compile(r'^([a-zA-Z_]+) = (.*)$') make = subprocess.Popen(['make', '-p', '/dev/null'], stdout=subprocess.PIPE) for l in make.stdout: @@ -398,7 +398,7 @@ class UDisksTestCase(unittest.TestCase): make.wait() # expand make variables - subst_re = re.compile('\${([a-zA-Z_]+)}') + subst_re = re.compile(r'${([a-zA-Z_]+)}') for (k, v) in make_vars.items(): while True: m = subst_re.search(v) @@ -1044,13 +1044,13 @@ class FS(UDisksTestCase): # change label supported = True - l = 'n"a\m\\"e' + fs_type + l = r'n"a$m\"e' + fs_type if fs_type == 'vfat': # VFAT does not support some characters self.assertRaises(GLib.GError, fs.call_set_label_sync, l, no_options, None) - l = "n@a$me" + l = r'n@a$me' elif fs_type == 'exfat': - l = 'n"a\m\\"exft' + l = r'n"a$m\"exft' try: fs.call_set_label_sync(l, no_options, None) except GLib.GError as e: From 11dfecfd1f0805ab851825310a98176413647dcc Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 7 Aug 2023 17:10:48 +0200 Subject: [PATCH 2/2] tests: Fix regex escaping --- src/tests/dbus-tests/test_30_iscsi.py | 2 +- src/tests/dbus-tests/test_80_filesystem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py index 6ecf22a4f..7e71c4bf8 100644 --- a/src/tests/dbus-tests/test_30_iscsi.py +++ b/src/tests/dbus-tests/test_30_iscsi.py @@ -164,7 +164,7 @@ def test_login_chap_auth(self): options['node.session.auth.chap_algs'] = 'SHA3-256,SHA256,SHA1' # disallow MD5 options['username'] = self.initiator - msg = 'Login failed: initiator reported error \(24 - iSCSI login failed due to authorization failure\)' + msg = r'Login failed: initiator reported error \(24 - iSCSI login failed due to authorization failure\)' # missing auth info with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg): manager.Login(iqn, tpg, host, port, iface, self.no_options, diff --git a/src/tests/dbus-tests/test_80_filesystem.py b/src/tests/dbus-tests/test_80_filesystem.py index 71c011ae0..59946720c 100644 --- a/src/tests/dbus-tests/test_80_filesystem.py +++ b/src/tests/dbus-tests/test_80_filesystem.py @@ -482,7 +482,7 @@ def test_custom_option(self, should_fail, dbus_option, should_be_present, config else: mnt_path = block_fs.Mount(dd, dbus_interface=self.iface_prefix + '.Filesystem') self.assertTrue(os.path.ismount(mnt_path)) - _ret, out = self.run_command('mount | grep %s | sed "s/.*(\(.*\))/\\1/"' % block_fs_dev) + _ret, out = self.run_command(r'mount | grep %s | sed "s/.*(\(.*\))/\\1/"' % block_fs_dev) if dbus_option is not None: if should_be_present: self.assertIn(dbus_option, out)