annotate tests/test_merge.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
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: 46
diff changeset
3 from hglib.util import b
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 class test_merge(common.basetest):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def setUp(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 common.basetest.setUp(self)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.append('a', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
10 rev, self.node0 = self.client.commit(b('first'), addremove=True)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 self.append('a', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
13 rev, self.node1 = self.client.commit(b('change'))
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 def test_basic(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.client.update(self.node0)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.append('b', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
18 rev, node2 = self.client.commit(b('new file'), addremove=True)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.client.merge(self.node1)
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
20 rev, node = self.client.commit(b('merge'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
21 diff = b("diff -r ") + node2[:12] + b(" -r ") + node[:12] + b(""" a
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 --- a/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 +++ b/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 @@ -1,1 +1,1 @@
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 -a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 \ No newline at end of file
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 +aa
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28 \ No newline at end of file
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
29 """)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
31 self.assertEqual(diff, self.client.diff(change=node, nodates=True))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
32
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
33 def test_merge_prompt_abort(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
34 self.client.update(self.node0)
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
35 self.client.remove(b('a'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
36 self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
37
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
38 self.assertRaises(hglib.error.CommandError, self.client.merge)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
39
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
40 def test_merge_prompt_noninteractive(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
41 self.client.update(self.node0)
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
42 self.client.remove(b('a'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
43 rev, node = self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
44
173
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
45 if self.client.version >= (3, 7):
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
46 self.assertRaises(hglib.error.CommandError,
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
47 self.client.merge,
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
48 cb=hglib.merge.handlers.noninteractive)
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
49 else:
8c4d24b58c23 tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents: 148
diff changeset
50 self.client.merge(cb=hglib.merge.handlers.noninteractive)
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
51
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
52 diff = b("diff -r ") + node[:12] + b(""" a
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
53 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
54 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
55 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
56 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
57 \ No newline at end of file
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
58 """)
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
59 self.assertEqual(diff, self.client.diff(nodates=True))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
60
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
61 def test_merge_prompt_cb(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
62 self.client.update(self.node0)
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
63 self.client.remove(b('a'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
64 rev, node = self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
65
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
66 def cb(output):
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
67 return b('c')
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
68
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
69 self.client.merge(cb=cb)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
70
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
71 diff = b("diff -r ") + node[:12] + b(""" a
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
72 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
73 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
74 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
75 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
76 \ No newline at end of file
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
77 """)
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
78 self.assertEqual(diff, self.client.diff(nodates=True))