Mercurial > python-hglib
annotate tests/test-grep.py @ 147:98829bf71f10
util: define BytesIO in one place
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 13 Mar 2015 12:28:06 -0500 |
parents | 4359cabcb0cc |
children | c1b966866ed7 |
rev | line source |
---|---|
56 | 1 import common |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
2 from hglib.util import b |
56 | 3 |
4 class test_grep(common.basetest): | |
5 def test_basic(self): | |
6 self.append('a', 'a\n') | |
7 self.append('b', 'ab\n') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
8 self.client.commit(b('first'), addremove=True) |
56 | 9 |
10 # no match | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
11 self.assertEquals(list(self.client.grep(b('c'))), []) |
56 | 12 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
13 self.assertEquals(list(self.client.grep(b('a'))), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
14 [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
15 self.assertEquals(list(self.client.grep(b('a'), b('a'))), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
16 [(b('a'), b('0'), b('a'))]) |
56 | 17 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
18 self.assertEquals(list(self.client.grep(b('b'))), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
19 [(b('b'), b('0'), b('ab'))]) |
56 | 20 |
21 def test_options(self): | |
22 self.append('a', 'a\n') | |
23 self.append('b', 'ab\n') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
24 rev, node = self.client.commit(b('first'), addremove=True) |
56 | 25 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
26 self.assertEquals([(b('a'), b('0'), b('+'), b('a')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
27 (b('b'), b('0'), b('+'), b('ab'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
28 list(self.client.grep(b('a'), all=True))) |
56 | 29 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
30 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
31 list(self.client.grep(b('a'), fileswithmatches=True))) |
56 | 32 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
33 self.assertEquals([(b('a'), b('0'), b('1'), b('a')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
34 (b('b'), b('0'), b('1'), b('ab'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
35 list(self.client.grep(b('a'), line=True))) |
56 | 36 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
37 self.assertEquals([(b('a'), b('0'), b('test'), b('a')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
38 (b('b'), b('0'), b('test'), b('ab'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
39 list(self.client.grep(b('a'), user=True))) |
56 | 40 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
41 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
42 (b('b'), b('0'), b('1'), b('+'), b('test'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
43 list(self.client.grep(b('a'), all=True, user=True, |
134 | 44 line=True, |
56 | 45 fileswithmatches=True))) |