Mercurial > python-hglib
annotate tests/test_log.py @ 225:fba806958dba
tests: add regression test to check for null byte handling
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Tue, 14 Mar 2023 14:35:58 +0100 |
parents | a2afbf236ca8 |
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 |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 import hglib |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
3 from hglib.util import b |
225
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
4 import subprocess |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 class test_log(common.basetest): |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 def test_basic(self): |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
9 rev0, node0 = self.client.commit(b('first'), addremove=True) |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
11 rev1, node1 = self.client.commit(b('second')) |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 revs = self.client.log() |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 revs.reverse() |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 self.assertTrue(len(revs) == 2) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
17 self.assertEqual(revs[1].node, node1) |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
19 self.assertEqual(revs[0], self.client.log(b('0'))[0]) |
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
20 self.assertEqual(self.client.log(), self.client.log(files=[b('a')])) |
110
c635e6e7054f
context: raise same error when not found for all hg versions
Alexander Plavin <me@aplavin.ru>
parents:
17
diff
changeset
|
21 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
22 self.assertEqual(self.client.log(), self.client.log(hidden=True)) |
120
5d3783aebe5f
log: fix 'hidden' option
Julien Cristau <julien.cristau@logilab.fr>
parents:
110
diff
changeset
|
23 |
193
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
24 def test_dash_in_filename(self): |
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
25 self.append('-a', '-a') |
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
26 self.client.commit(b('first'), addremove=True) |
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
27 revs = self.client.log(files=[b('-a')]) |
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
28 self.assertTrue(len(revs) == 1) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
29 self.assertEqual(revs[0].rev, b('0')) |
193
32e8d51ec16c
util: make cmdbuilder() robust for faulty parsing of early options
Yuya Nishihara <yuya@tcha.org>
parents:
148
diff
changeset
|
30 |
205
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
31 def test_empty_short_option(self): |
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
32 self.append('foobar', 'foobar') |
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
33 self.client.commit(b('first'), addremove=True) |
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
34 revs = self.client.log(keyword=b(''), files=[b('foobar')]) |
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
35 self.assertTrue(len(revs) == 1) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
36 self.assertEqual(revs[0].rev, b('0')) |
205
2d0ec6097d78
util: fix handling of empty short option
Yuya Nishihara <yuya@tcha.org>
parents:
193
diff
changeset
|
37 |
225
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
38 def test_null_byte(self): |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
39 self.append('a', 'a') |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
40 with open('commitmessagenullbyte', 'w') as f: |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
41 f.write('some message\0more stuff') |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
42 # use 'hg' directly here as hglib doesn't allow |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
43 # committing null byte descriptions |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
44 subprocess.check_call(["hg", "commit", |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
45 "-l", "commitmessagenullbyte", "--addremove", "-q"]) |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
46 revs = self.client.log(revrange=b('.')) |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
47 self.assertEqual(revs[0].desc, b('some message\0more stuff')) |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
48 |
110
c635e6e7054f
context: raise same error when not found for all hg versions
Alexander Plavin <me@aplavin.ru>
parents:
17
diff
changeset
|
49 # def test_errors(self): |
134 | 50 # self.assertRaisesRegexp(CommandError, 'abort: unknown revision', |
51 # self.client.log, 'foo') | |
110
c635e6e7054f
context: raise same error when not found for all hg versions
Alexander Plavin <me@aplavin.ru>
parents:
17
diff
changeset
|
52 # self.append('a', 'a') |
c635e6e7054f
context: raise same error when not found for all hg versions
Alexander Plavin <me@aplavin.ru>
parents:
17
diff
changeset
|
53 # self.client.commit('first', addremove=True) |
134 | 54 # self.assertRaisesRegexp(CommandError, |
55 # 'abort: unknown revision', | |
56 # self.client.log, 'bar') |