Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-status.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 | 4359cabcb0cc |
children | c1b966866ed7 |
rev | line source |
---|---|
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1 import common, os |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
2 from hglib.util import b |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 class test_status(common.basetest): |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 def test_empty(self): |
34
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
6 self.assertEquals(self.client.status(), []) |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 def test_one_of_each(self): |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 self.append('.hgignore', 'ignored') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 self.append('ignored', 'a') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 self.append('clean', 'a') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 self.append('modified', 'a') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 self.append('removed', 'a') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 self.append('missing', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
15 self.client.commit(b('first'), addremove=True) |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 self.append('modified', 'a') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 self.append('added', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
18 self.client.add([b('added')]) |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
19 os.remove('missing') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
20 self.client.remove([b('removed')]) |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
21 self.append('untracked') |
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
22 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
23 l = [(b('M'), b('modified')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
24 (b('A'), b('added')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
25 (b('R'), b('removed')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
26 (b('C'), b('.hgignore')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
27 (b('C'), b('clean')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
28 (b('!'), b('missing')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
29 (b('?'), b('untracked')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
30 (b('I'), b('ignored'))] |
33
d74a5891d9d1
client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
31 |
34
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
32 st = self.client.status(all=True) |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
33 |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
34 for i in l: |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
35 self.assertTrue(i in st) |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
36 |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
37 def test_copy(self): |
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
38 self.append('source', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
39 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:
35
diff
changeset
|
40 self.client.copy(b('source'), b('dest')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
41 l = [(b('A'), b('dest')), (b(' '), b('source'))] |
34
f6e1d9a6e0cd
client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents:
33
diff
changeset
|
42 self.assertEquals(self.client.status(copies=True), l) |
35
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
43 |
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
44 def test_copy_origin_space(self): |
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
45 self.append('s ource', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
46 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:
35
diff
changeset
|
47 self.client.copy(b('s ource'), b('dest')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
35
diff
changeset
|
48 l = [(b('A'), b('dest')), (b(' '), b('s ource'))] |
35
1e33bbea23e5
client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents:
34
diff
changeset
|
49 self.assertEquals(self.client.status(copies=True), l) |