File: test-grep.py

package info (click to toggle)
python-hglib 1.4-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 312 kB
  • sloc: python: 2,098; makefile: 20
file content (39 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import common

class test_grep(common.basetest):
    def test_basic(self):
        self.append('a', 'a\n')
        self.append('b', 'ab\n')
        self.client.commit('first', addremove=True)

        # no match
        self.assertEquals(list(self.client.grep('c')), [])

        self.assertEquals(list(self.client.grep('a')),
                          [('a', '0', 'a'), ('b', '0', 'ab')])
        self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')])

        self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')])

    def test_options(self):
        self.append('a', 'a\n')
        self.append('b', 'ab\n')
        rev, node = self.client.commit('first', addremove=True)

        self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')],
                          list(self.client.grep('a', all=True)))

        self.assertEquals([('a', '0'), ('b', '0')],
                          list(self.client.grep('a', fileswithmatches=True)))

        self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')],
                          list(self.client.grep('a', line=True)))

        self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')],
                          list(self.client.grep('a', user=True)))

        self.assertEquals([('a', '0', '1', '+', 'test'),
                           ('b', '0', '1', '+', 'test')],
                          list(self.client.grep('a', all=True, user=True,
                                                line=True,
                                                fileswithmatches=True)))