test: fix DeprecationWarning: invalid escape sequence
Change-Id: I4e0365c1f9d30a033b26f68f815c8209b96d73f5 Reviewed-on: https://code.wireshark.org/review/30164 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
a4cf169f1e
commit
fe9dcc1647
|
@ -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))
|
||||
|
|
|
@ -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'''
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue