comparison tests/test_grep.py @ 221:a2afbf236ca8

hglib tests: remove deprecated constructions This mostly removes usage of 'assertEquals' (replaced with 'assertEqual'), as well as opening files without closing them (fixed using a 'with' statement).
author Mathias De Mare <mathias.de_mare@nokia.com>
date Thu, 09 Mar 2023 14:00:02 +0100
parents 8341f2494b3f
children
comparison
equal deleted inserted replaced
220:ae6427d1c8f7 221:a2afbf236ca8
6 self.append('a', 'x\n') 6 self.append('a', 'x\n')
7 self.append('b', 'xy\n') 7 self.append('b', 'xy\n')
8 self.client.commit(b('first'), addremove=True) 8 self.client.commit(b('first'), addremove=True)
9 9
10 # no match 10 # no match
11 self.assertEquals(list(self.client.grep(b('c'))), []) 11 self.assertEqual(list(self.client.grep(b('c'))), [])
12 12
13 if self.client.version >= (5, 2): 13 if self.client.version >= (5, 2):
14 self.assertEquals(list(self.client.grep(b('x'))), 14 self.assertEqual(list(self.client.grep(b('x'))),
15 [(b('a'), b('x')), (b('b'), b('xy'))]) 15 [(b('a'), b('x')), (b('b'), b('xy'))])
16 self.assertEquals(list(self.client.grep(b('x'), b('a'))), 16 self.assertEqual(list(self.client.grep(b('x'), b('a'))),
17 [(b('a'), b('x'))]) 17 [(b('a'), b('x'))])
18 18
19 self.assertEquals(list(self.client.grep(b('y'))), 19 self.assertEqual(list(self.client.grep(b('y'))),
20 [(b('b'), b('xy'))]) 20 [(b('b'), b('xy'))])
21 else: 21 else:
22 self.assertEquals(list(self.client.grep(b('x'))), 22 self.assertEqual(list(self.client.grep(b('x'))),
23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))]) 23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))])
24 self.assertEquals(list(self.client.grep(b('x'), b('a'))), 24 self.assertEqual(list(self.client.grep(b('x'), b('a'))),
25 [(b('a'), b('0'), b('x'))]) 25 [(b('a'), b('0'), b('x'))])
26 self.assertEquals(list(self.client.grep(b('y'))), 26 self.assertEqual(list(self.client.grep(b('y'))),
27 [(b('b'), b('0'), b('xy'))]) 27 [(b('b'), b('0'), b('xy'))])
28 28
29 def test_options(self): 29 def test_options(self):
30 self.append('a', 'x\n') 30 self.append('a', 'x\n')
31 self.append('b', 'xy\n') 31 self.append('b', 'xy\n')
32 rev, node = self.client.commit(b('first'), addremove=True) 32 rev, node = self.client.commit(b('first'), addremove=True)
33 33
34 self.assertEquals([(b('a'), b('0'), b('+'), b('x')), 34 self.assertEqual([(b('a'), b('0'), b('+'), b('x')),
35 (b('b'), b('0'), b('+'), b('xy'))], 35 (b('b'), b('0'), b('+'), b('xy'))],
36 list(self.client.grep(b('x'), all=True))) 36 list(self.client.grep(b('x'), all=True)))
37 37
38 if self.client.version >= (5, 2): 38 if self.client.version >= (5, 2):
39 self.assertEquals([(b('a'),), (b('b'),)], 39 self.assertEqual([(b('a'),), (b('b'),)],
40 list(self.client.grep(b('x'), fileswithmatches=True))) 40 list(self.client.grep(b('x'), fileswithmatches=True)))
41 41
42 self.assertEquals([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))], 42 self.assertEqual([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))],
43 list(self.client.grep(b('x'), line=True))) 43 list(self.client.grep(b('x'), line=True)))
44 44
45 self.assertEquals([(b('a'), b('test'), b('x')), 45 self.assertEqual([(b('a'), b('test'), b('x')),
46 (b('b'), b('test'), b('xy'))], 46 (b('b'), b('test'), b('xy'))],
47 list(self.client.grep(b('x'), user=True))) 47 list(self.client.grep(b('x'), user=True)))
48 else: 48 else:
49 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], 49 self.assertEqual([(b('a'), b('0')), (b('b'), b('0'))],
50 list(self.client.grep(b('x'), fileswithmatches=True))) 50 list(self.client.grep(b('x'), fileswithmatches=True)))
51 51
52 self.assertEquals([(b('a'), b('0'), b('1'), b('x')), 52 self.assertEqual([(b('a'), b('0'), b('1'), b('x')),
53 (b('b'), b('0'), b('1'), b('xy'))], 53 (b('b'), b('0'), b('1'), b('xy'))],
54 list(self.client.grep(b('x'), line=True))) 54 list(self.client.grep(b('x'), line=True)))
55 55
56 self.assertEquals([(b('a'), b('0'), b('test'), b('x')), 56 self.assertEqual([(b('a'), b('0'), b('test'), b('x')),
57 (b('b'), b('0'), b('test'), b('xy'))], 57 (b('b'), b('0'), b('test'), b('xy'))],
58 list(self.client.grep(b('x'), user=True))) 58 list(self.client.grep(b('x'), user=True)))
59 59
60 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), 60 self.assertEqual([(b('a'), b('0'), b('1'), b('+'), b('test')),
61 (b('b'), b('0'), b('1'), b('+'), b('test'))], 61 (b('b'), b('0'), b('1'), b('+'), b('test'))],
62 list(self.client.grep(b('x'), all=True, user=True, 62 list(self.client.grep(b('x'), all=True, user=True,
63 line=True, 63 line=True,
64 fileswithmatches=True))) 64 fileswithmatches=True)))