Skip to content

Commit 4818f65

Browse files
musicinmybrainalanking
authored andcommitted
[#687] Fix some SyntaxWarnings in the tests
Change strings with backslashes that are not intended to be part of backslash escape sequences to raw strings. Most but not all such strings are regular expression patterns. Fixes a number of instances of: SyntaxWarning: invalid escape sequence
1 parent e561032 commit 4818f65

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

irods/test/admin_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def test_set_user_password(self):
376376
self.sess.users.create(self.new_user_name, self.new_user_type)
377377

378378
# make a really horrible password
379-
new_password = """abc123!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~Z"""
379+
new_password = r"""abc123!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~Z"""
380380
self.sess.users.modify(username, "password", new_password)
381381

382382
# open a session as the new user
@@ -403,7 +403,7 @@ def test_set_user_comment(self):
403403
self.sess.users.create(self.new_user_name, self.new_user_type)
404404

405405
# modify user comment
406-
new_comment = """comment-abc123!"#$%&'()*+,-./:;<=>?@[\]^_{|}~Z""" # omitting backtick due to #170
406+
new_comment = r"""comment-abc123!"#$%&'()*+,-./:;<=>?@[\]^_{|}~Z""" # omitting backtick due to #170
407407
self.sess.users.modify(self.new_user_name, "comment", new_comment)
408408

409409
# check comment was modified
@@ -422,7 +422,7 @@ def test_set_user_info(self):
422422
self.sess.users.create(self.new_user_name, self.new_user_type)
423423

424424
# modify user info
425-
new_info = """info-abc123!"#$%&'()*+,-./:;<=>?@[\]^_{|}~Z""" # omitting backtick due to #170
425+
new_info = r"""info-abc123!"#$%&'()*+,-./:;<=>?@[\]^_{|}~Z""" # omitting backtick due to #170
426426
self.sess.users.modify(self.new_user_name, "info", new_info)
427427

428428
# check info was modified

irods/test/data_obj_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
progressbar = None
3535

3636
ip_pattern = re.compile(r"(\d+)\.(\d+)\.(\d+)\.(\d+)$")
37-
localhost_with_optional_domain_pattern = re.compile("localhost(\.\S\S*)?$")
37+
localhost_with_optional_domain_pattern = re.compile(r"localhost(\.\S\S*)?$")
3838

3939

4040
def is_localhost_ip(s):
@@ -268,7 +268,7 @@ def write_and_check_replica_on_parallel_connections(
268268
required_num_replicas=1,
269269
seconds_to_wait_for_replicas=10,
270270
):
271-
"""Helper function for testing irods/irods#5548 and irods/irods#5848.
271+
r"""Helper function for testing irods/irods#5548 and irods/irods#5848.
272272
273273
Writes the string "books\n" to a replica, but not as a single write operation.
274274
It is done piecewise on two independent connections, essentially simulating parallel "put".
@@ -417,7 +417,7 @@ def test_put_get_parallel_autoswitch_A__235(self):
417417

418418
PUT_LOG = io.StringIO()
419419
GET_LOG = io.StringIO()
420-
NumThreadsRegex = re.compile("^num_threads\s*=\s*(\d+)", re.MULTILINE)
420+
NumThreadsRegex = re.compile(r"^num_threads\s*=\s*(\d+)", re.MULTILINE)
421421

422422
try:
423423
logger = logging.getLogger("irods.parallel")
@@ -601,7 +601,7 @@ def test_verify_chksum__282_287(self):
601601
)
602602

603603
NO_CHECKSUM_MESSAGE_PATTERN = re.compile(
604-
"No\s+Checksum\s+Available.+\s+Replica\s\[(\d+)\]", re.IGNORECASE
604+
r"No\s+Checksum\s+Available.+\s+Replica\s\[(\d+)\]", re.IGNORECASE
605605
)
606606

607607
Reported_repls_without_checksum = set(
@@ -1046,8 +1046,8 @@ def assert_expected_redirection_logging(BUF):
10461046
nthr = 0
10471047
search_text = BUF.getvalue()
10481048
find_iterator = itertools.chain(
1049-
re.finditer("redirect_to_host = (\S+)", search_text),
1050-
re.finditer("target_host = (\S+)", search_text),
1049+
re.finditer(r"redirect_to_host = (\S+)", search_text),
1050+
re.finditer(r"target_host = (\S+)", search_text),
10511051
)
10521052
for match in find_iterator:
10531053
nthr += 1

irods/test/rule_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def test_rulefile_in_file_like_object_1__336(self):
420420
)
421421
output = r.execute()
422422
lines = self.lines_from_stdout_buf(output)
423-
self.assertRegexpMatches(lines[0], ".*\[Hello world!\]")
423+
self.assertRegexpMatches(lines[0], r".*\[Hello world!\]")
424424

425425
def test_rulefile_in_file_like_object_2__336(self):
426426

@@ -442,8 +442,8 @@ def test_rulefile_in_file_like_object_2__336(self):
442442
r = Rule(self.sess, rule_file=io.BytesIO(rule_file_contents.encode("utf-8")))
443443
output = r.execute()
444444
lines = self.lines_from_stdout_buf(output)
445-
self.assertRegexpMatches(lines[0], "\[STRING\]\[\]")
446-
self.assertRegexpMatches(lines[1], "\[STRING\]\[\]")
445+
self.assertRegexpMatches(lines[0], r"\[STRING\]\[\]")
446+
self.assertRegexpMatches(lines[1], r"\[STRING\]\[\]")
447447

448448
r = Rule(
449449
self.sess,
@@ -452,8 +452,8 @@ def test_rulefile_in_file_like_object_2__336(self):
452452
)
453453
output = r.execute()
454454
lines = self.lines_from_stdout_buf(output)
455-
self.assertRegexpMatches(lines[0], "\[INTEGER\]\[5\]")
456-
self.assertRegexpMatches(lines[1], "\[STRING\]\[A String\]")
455+
self.assertRegexpMatches(lines[0], r"\[INTEGER\]\[5\]")
456+
self.assertRegexpMatches(lines[1], r"\[STRING\]\[A String\]")
457457

458458

459459
if __name__ == "__main__":

0 commit comments

Comments
 (0)