Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-commit.py @ 145:f3c430afa598
hglib: abstract out use of cStringIO.StringIO (issue4520)
The cStringIO module does not exist in Python 3, but io.BytesIO does.
This change prepares for the use of io.BytesIO when available by
replacing all uses of cStringIO.StringIO with an object named BytesIO.
author | Brett Cannon <brett@python.org> |
---|---|
date | Fri, 13 Mar 2015 11:31:54 -0400 |
parents | 3c59643a2bc3 |
children | c1b966866ed7 |
rev | line source |
---|---|
99
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
1 import common, hglib, datetime |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
2 from hglib.util import b |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 class test_commit(common.basetest): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 def test_user(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
7 rev, node = self.client.commit(b('first'), addremove=True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
8 user=b('foo')) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 rev = self.client.log(node)[0] |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
10 self.assertEquals(rev.author, b('foo')) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 def test_no_user(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 self.append('a', 'a') |
134 | 14 self.assertRaises(hglib.error.CommandError, |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
15 self.client.commit, b('first'), user=b('')) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 def test_close_branch(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
19 rev0, node0 = self.client.commit(b('first'), addremove=True) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
20 self.client.branch(b('foo')) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
21 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
22 rev1, node1 = self.client.commit(b('second')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
23 revclose = self.client.commit(b('closing foo'), closebranch=True) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
24 rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
25 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
26 self.assertEquals(self.client.branches(), |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
27 [(rev0.branch, int(rev0.rev), rev0.node[:12])]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
28 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
29 self.assertEquals(self.client.branches(closed=True), |
134 | 30 [(revclose.branch, int(revclose.rev), |
31 revclose.node[:12]), | |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
32 (rev0.branch, int(rev0.rev), rev0.node[:12])]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
33 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
34 def test_message_logfile(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
35 self.assertRaises(ValueError, self.client.commit, b('foo'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
36 logfile=b('bar')) |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
37 self.assertRaises(ValueError, self.client.commit) |
99
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
38 |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
39 def test_date(self): |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
40 self.append('a', 'a') |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
41 now = datetime.datetime.now().replace(microsecond=0) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
42 rev0, node0 = self.client.commit( |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
43 b('first'), addremove=True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
44 date=now.isoformat(' ').encode('latin-1')) |
99
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
45 |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
46 self.assertEquals(now, self.client.tip().date) |
136
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
47 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
48 def test_amend(self): |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
49 self.append('a', 'a') |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
50 now = datetime.datetime.now().replace(microsecond=0) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
51 rev0, node0 = self.client.commit( |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
52 b('first'), addremove=True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
136
diff
changeset
|
53 date=now.isoformat(' ').encode('latin-1')) |
136
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
54 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
55 self.assertEquals(now, self.client.tip().date) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
56 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
57 self.append('a', 'a') |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
58 rev1, node1 = self.client.commit(amend=True) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
59 self.assertEquals(now, self.client.tip().date) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
60 self.assertNotEquals(node0, node1) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
61 self.assertEqual(1, len(self.client.log())) |