From fe9dcc1647250d68b34d0222250d985f2fff724b Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 12 Oct 2018 14:12:41 +0200 Subject: [PATCH] test: fix DeprecationWarning: invalid escape sequence Change-Id: I4e0365c1f9d30a033b26f68f815c8209b96d73f5 Reviewed-on: https://code.wireshark.org/review/30164 Petri-Dish: Peter Wu Reviewed-by: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- test/subprocesstest.py | 2 +- test/suite_decryption.py | 2 +- test/suite_mergecap.py | 10 +++++----- test/suite_text2pcap.py | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/subprocesstest.py b/test/subprocesstest.py index 2f05137bbf..96edb259c1 100644 --- a/test/subprocesstest.py +++ b/test/subprocesstest.py @@ -225,7 +225,7 @@ class SubprocessTestCase(unittest.TestCase): '''Make sure a capture file contains a specific number of packets.''' got_num_packets = False capinfos_testout = self.getCaptureInfo(cap_file=cap_file) - count_pat = 'Number of packets:\s+{}'.format(num_packets) + count_pat = r'Number of packets:\s+{}'.format(num_packets) if re.search(count_pat, capinfos_testout): got_num_packets = True self.assertTrue(got_num_packets, 'Failed to capture exactly {} packets'.format(num_packets)) diff --git a/test/suite_decryption.py b/test/suite_decryption.py index 0ec47dc18d..e393bf4d93 100644 --- a/test/suite_decryption.py +++ b/test/suite_decryption.py @@ -177,7 +177,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): '-Y', 'http', ), env=config.test_env) - self.assertTrue(self.grepOutput('GET\s+/test\s+HTTP/1.0')) + self.assertTrue(self.grepOutput(r'GET\s+/test\s+HTTP/1.0')) def test_tls12_renegotiation(self): '''TLS 1.2 with renegotiation''' diff --git a/test/suite_mergecap.py b/test/suite_mergecap.py index f9100a8c49..96dc497ded 100644 --- a/test/suite_mergecap.py +++ b/test/suite_mergecap.py @@ -60,23 +60,23 @@ def check_mergecap(self, mergecap_proc, file_type, encapsulation, tot_packets, g capinfos_testout = self.getCaptureInfo(capinfos_args=('-t', '-E', '-I', '-c'), cap_file=testout_file) file_descr = file_type_to_descr[file_type] - type_pat = 'File type:\s+{}'.format(file_descr) + type_pat = r'File type:\s+{}'.format(file_descr) self.assertTrue(re.search(type_pat, capinfos_testout) is not None, 'Failed to generate a {} file'.format(file_type)) - encap_pat = 'File encapsulation:\s+{}'.format(encapsulation) + encap_pat = r'File encapsulation:\s+{}'.format(encapsulation) self.assertTrue(re.search(encap_pat, capinfos_testout) is not None, 'Failed to generate an {} encapsulation'.format(encapsulation)) - pkt_pat = 'Number of packets:\s+{}'.format(tot_packets) + pkt_pat = r'Number of packets:\s+{}'.format(tot_packets) self.assertTrue(re.search(pkt_pat, capinfos_testout) is not None, 'Failed to generate {} packets'.format(tot_packets)) - gidb_pat = 'Number of interfaces in file:\s+{}'.format(generated_idbs) + gidb_pat = r'Number of interfaces in file:\s+{}'.format(generated_idbs) self.assertTrue(re.search(gidb_pat, capinfos_testout) is not None, 'Failed to generate {} IDBs'.format(generated_idbs)) - midb_pat = '\s+Number of packets\s+=\s+{}'.format(idb_packets) + midb_pat = r'\s+Number of packets\s+=\s+{}'.format(idb_packets) self.assertTrue(re.search(midb_pat, capinfos_testout) is not None, 'Failed to merge {} IDB packets'.format(idb_packets)) diff --git a/test/suite_text2pcap.py b/test/suite_text2pcap.py index 2a0e75f1dd..e4ff07bd0e 100644 --- a/test/suite_text2pcap.py +++ b/test/suite_text2pcap.py @@ -80,13 +80,13 @@ def check_capinfos_info(self, cap_file): for ci_line in capinfos_out.splitlines(): for sp_key in str_pats: - str_pat = '{}:\s+([\S ]+)'.format(str_pats[sp_key]) + str_pat = r'{}:\s+([\S ]+)'.format(str_pats[sp_key]) str_res = re.search(str_pat, ci_line) if str_res is not None: cap_info[sp_key] = str_res.group(1) for ip_key in int_pats: - int_pat = '{}:\s+(\d+)'.format(int_pats[ip_key]) + int_pat = r'{}:\s+(\d+)'.format(int_pats[ip_key]) int_res = re.search(int_pat, ci_line) if int_res is not None: cap_info[ip_key] = int(int_res.group(1)) @@ -263,7 +263,7 @@ class case_text2pcap_eol_hash(subprocesstest.SubprocessTestCase): testout_file, )) self.assertFalse(self.grepOutput('Inconsistent offset'), 'text2pcap failed to parse the hash sign at the end of the line') - self.assertTrue(self.grepOutput('Directive \[ test_directive'), 'text2pcap failed to parse #TEXT2PCAP test_directive') + self.assertTrue(self.grepOutput(r'Directive \[ test_directive'), 'text2pcap failed to parse #TEXT2PCAP test_directive') pre_cmp_info = {'encapsulation': 'Ethernet', 'packets': 1, 'datasize': 96 } post_cmp_info = check_capinfos_info(self, testout_file) compare_capinfos_info(self, pre_cmp_info, post_cmp_info, txt_fname, testout_pcap)