comparison tests/test_grep.py @ 219:8341f2494b3f

hglib tests: migrate away from (unmaintained) nose
author Mathias De Mare <mathias.de_mare@nokia.com>
date Wed, 08 Mar 2023 17:04:58 +0100
parents tests/test-grep.py@388820908580
children a2afbf236ca8
comparison
equal deleted inserted replaced
218:934608d4fcba 219:8341f2494b3f
1 from tests import common
2 from hglib.util import b
3
4 class test_grep(common.basetest):
5 def test_basic(self):
6 self.append('a', 'x\n')
7 self.append('b', 'xy\n')
8 self.client.commit(b('first'), addremove=True)
9
10 # no match
11 self.assertEquals(list(self.client.grep(b('c'))), [])
12
13 if self.client.version >= (5, 2):
14 self.assertEquals(list(self.client.grep(b('x'))),
15 [(b('a'), b('x')), (b('b'), b('xy'))])
16 self.assertEquals(list(self.client.grep(b('x'), b('a'))),
17 [(b('a'), b('x'))])
18
19 self.assertEquals(list(self.client.grep(b('y'))),
20 [(b('b'), b('xy'))])
21 else:
22 self.assertEquals(list(self.client.grep(b('x'))),
23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))])
24 self.assertEquals(list(self.client.grep(b('x'), b('a'))),
25 [(b('a'), b('0'), b('x'))])
26 self.assertEquals(list(self.client.grep(b('y'))),
27 [(b('b'), b('0'), b('xy'))])
28
29 def test_options(self):
30 self.append('a', 'x\n')
31 self.append('b', 'xy\n')
32 rev, node = self.client.commit(b('first'), addremove=True)
33
34 self.assertEquals([(b('a'), b('0'), b('+'), b('x')),
35 (b('b'), b('0'), b('+'), b('xy'))],
36 list(self.client.grep(b('x'), all=True)))
37
38 if self.client.version >= (5, 2):
39 self.assertEquals([(b('a'),), (b('b'),)],
40 list(self.client.grep(b('x'), fileswithmatches=True)))
41
42 self.assertEquals([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))],
43 list(self.client.grep(b('x'), line=True)))
44
45 self.assertEquals([(b('a'), b('test'), b('x')),
46 (b('b'), b('test'), b('xy'))],
47 list(self.client.grep(b('x'), user=True)))
48 else:
49 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))],
50 list(self.client.grep(b('x'), fileswithmatches=True)))
51
52 self.assertEquals([(b('a'), b('0'), b('1'), b('x')),
53 (b('b'), b('0'), b('1'), b('xy'))],
54 list(self.client.grep(b('x'), line=True)))
55
56 self.assertEquals([(b('a'), b('0'), b('test'), b('x')),
57 (b('b'), b('0'), b('test'), b('xy'))],
58 list(self.client.grep(b('x'), user=True)))
59
60 self.assertEquals([(b('a'), 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,
63 line=True,
64 fileswithmatches=True)))