comparison tests/test-grep.py @ 143:4359cabcb0cc

hglib: move string literals in the test code to util.b() (issue4520)
author Brett Cannon <brett@python.org>
date Mon, 09 Mar 2015 18:26:25 -0400
parents 1b47146a4a2c
children c1b966866ed7
comparison
equal deleted inserted replaced
142:fe74d5599539 143:4359cabcb0cc
1 import common 1 import common
2 from hglib.util import b
2 3
3 class test_grep(common.basetest): 4 class test_grep(common.basetest):
4 def test_basic(self): 5 def test_basic(self):
5 self.append('a', 'a\n') 6 self.append('a', 'a\n')
6 self.append('b', 'ab\n') 7 self.append('b', 'ab\n')
7 self.client.commit('first', addremove=True) 8 self.client.commit(b('first'), addremove=True)
8 9
9 # no match 10 # no match
10 self.assertEquals(list(self.client.grep('c')), []) 11 self.assertEquals(list(self.client.grep(b('c'))), [])
11 12
12 self.assertEquals(list(self.client.grep('a')), 13 self.assertEquals(list(self.client.grep(b('a'))),
13 [('a', '0', 'a'), ('b', '0', 'ab')]) 14 [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))])
14 self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')]) 15 self.assertEquals(list(self.client.grep(b('a'), b('a'))),
16 [(b('a'), b('0'), b('a'))])
15 17
16 self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')]) 18 self.assertEquals(list(self.client.grep(b('b'))),
19 [(b('b'), b('0'), b('ab'))])
17 20
18 def test_options(self): 21 def test_options(self):
19 self.append('a', 'a\n') 22 self.append('a', 'a\n')
20 self.append('b', 'ab\n') 23 self.append('b', 'ab\n')
21 rev, node = self.client.commit('first', addremove=True) 24 rev, node = self.client.commit(b('first'), addremove=True)
22 25
23 self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')], 26 self.assertEquals([(b('a'), b('0'), b('+'), b('a')),
24 list(self.client.grep('a', all=True))) 27 (b('b'), b('0'), b('+'), b('ab'))],
28 list(self.client.grep(b('a'), all=True)))
25 29
26 self.assertEquals([('a', '0'), ('b', '0')], 30 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))],
27 list(self.client.grep('a', fileswithmatches=True))) 31 list(self.client.grep(b('a'), fileswithmatches=True)))
28 32
29 self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')], 33 self.assertEquals([(b('a'), b('0'), b('1'), b('a')),
30 list(self.client.grep('a', line=True))) 34 (b('b'), b('0'), b('1'), b('ab'))],
35 list(self.client.grep(b('a'), line=True)))
31 36
32 self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')], 37 self.assertEquals([(b('a'), b('0'), b('test'), b('a')),
33 list(self.client.grep('a', user=True))) 38 (b('b'), b('0'), b('test'), b('ab'))],
39 list(self.client.grep(b('a'), user=True)))
34 40
35 self.assertEquals([('a', '0', '1', '+', 'test'), 41 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')),
36 ('b', '0', '1', '+', 'test')], 42 (b('b'), b('0'), b('1'), b('+'), b('test'))],
37 list(self.client.grep('a', all=True, user=True, 43 list(self.client.grep(b('a'), all=True, user=True,
38 line=True, 44 line=True,
39 fileswithmatches=True))) 45 fileswithmatches=True)))