Mercurial > python-hglib
annotate 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 |
rev | line source |
---|---|
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
1 from tests 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): | |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
6 self.append('a', 'x\n') |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
7 self.append('b', 'xy\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 | |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
11 self.assertEqual(list(self.client.grep(b('c'))), []) |
56 | 12 |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
13 if self.client.version >= (5, 2): |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
14 self.assertEqual(list(self.client.grep(b('x'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
15 [(b('a'), b('x')), (b('b'), b('xy'))]) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
16 self.assertEqual(list(self.client.grep(b('x'), b('a'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
17 [(b('a'), b('x'))]) |
56 | 18 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
19 self.assertEqual(list(self.client.grep(b('y'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
20 [(b('b'), b('xy'))]) |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
21 else: |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
22 self.assertEqual(list(self.client.grep(b('x'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))]) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
24 self.assertEqual(list(self.client.grep(b('x'), b('a'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
25 [(b('a'), b('0'), b('x'))]) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
26 self.assertEqual(list(self.client.grep(b('y'))), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
27 [(b('b'), b('0'), b('xy'))]) |
56 | 28 |
29 def test_options(self): | |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
30 self.append('a', 'x\n') |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
31 self.append('b', 'xy\n') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
32 rev, node = self.client.commit(b('first'), addremove=True) |
56 | 33 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
34 self.assertEqual([(b('a'), b('0'), b('+'), b('x')), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
35 (b('b'), b('0'), b('+'), b('xy'))], |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
36 list(self.client.grep(b('x'), all=True))) |
56 | 37 |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
38 if self.client.version >= (5, 2): |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
39 self.assertEqual([(b('a'),), (b('b'),)], |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
40 list(self.client.grep(b('x'), fileswithmatches=True))) |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
41 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
42 self.assertEqual([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))], |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
43 list(self.client.grep(b('x'), line=True))) |
56 | 44 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
45 self.assertEqual([(b('a'), b('test'), b('x')), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
46 (b('b'), b('test'), b('xy'))], |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
47 list(self.client.grep(b('x'), user=True))) |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
48 else: |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
49 self.assertEqual([(b('a'), b('0')), (b('b'), b('0'))], |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
50 list(self.client.grep(b('x'), fileswithmatches=True))) |
56 | 51 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
52 self.assertEqual([(b('a'), b('0'), b('1'), b('x')), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
53 (b('b'), b('0'), b('1'), b('xy'))], |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
54 list(self.client.grep(b('x'), line=True))) |
211
1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents:
148
diff
changeset
|
55 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
56 self.assertEqual([(b('a'), b('0'), b('test'), b('x')), |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
57 (b('b'), b('0'), b('test'), b('xy'))], |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
58 list(self.client.grep(b('x'), user=True))) |
56 | 59 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
60 self.assertEqual([(b('a'), b('0'), b('1'), b('+'), b('test')), |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
61 (b('b'), b('0'), b('1'), b('+'), b('test'))], |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
62 list(self.client.grep(b('x'), all=True, user=True, |
134 | 63 line=True, |
56 | 64 fileswithmatches=True))) |