Mercurial > python-hglib
comparison tests/test-import.py @ 143:4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
author | Brett Cannon <brett@python.org> |
---|---|
date | Mon, 09 Mar 2015 18:26:25 -0400 |
parents | e738d6fe5f3f |
children | f3c430afa598 |
comparison
equal
deleted
inserted
replaced
142:fe74d5599539 | 143:4359cabcb0cc |
---|---|
1 import common, cStringIO, os | 1 import common, cStringIO, os |
2 import hglib | 2 import hglib |
3 from hglib.util import b | |
3 | 4 |
4 patch = """ | 5 patch = b(""" |
5 # HG changeset patch | 6 # HG changeset patch |
6 # User test | 7 # User test |
7 # Date 0 0 | 8 # Date 0 0 |
8 # Node ID c103a3dec114d882c98382d684d8af798d09d857 | 9 # Node ID c103a3dec114d882c98382d684d8af798d09d857 |
9 # Parent 0000000000000000000000000000000000000000 | 10 # Parent 0000000000000000000000000000000000000000 |
12 diff -r 000000000000 -r c103a3dec114 a | 13 diff -r 000000000000 -r c103a3dec114 a |
13 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 14 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
14 +++ b/a Thu Jan 01 00:00:00 1970 +0000 | 15 +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
15 @@ -0,0 +1,1 @@ | 16 @@ -0,0 +1,1 @@ |
16 +1 | 17 +1 |
17 """ | 18 """) |
18 | 19 |
19 class test_import(common.basetest): | 20 class test_import(common.basetest): |
20 def test_basic_cstringio(self): | 21 def test_basic_cstringio(self): |
21 self.client.import_(cStringIO.StringIO(patch)) | 22 self.client.import_(cStringIO.StringIO(patch)) |
22 self.assertEquals(self.client.cat(['a']), '1\n') | 23 self.assertEquals(self.client.cat([b('a')]), b('1\n')) |
23 | 24 |
24 def test_basic_file(self): | 25 def test_basic_file(self): |
25 f = open('patch', 'wb') | 26 f = open('patch', 'wb') |
26 f.write(patch) | 27 f.write(patch) |
27 f.close() | 28 f.close() |
28 | 29 |
29 # --no-commit | 30 # --no-commit |
30 self.client.import_(['patch'], nocommit=True) | 31 self.client.import_([b('patch')], nocommit=True) |
31 self.assertEquals(open('a').read(), '1\n') | 32 self.assertEquals(open('a').read(), '1\n') |
32 | 33 |
33 self.client.update(clean=True) | 34 self.client.update(clean=True) |
34 os.remove('a') | 35 os.remove('a') |
35 | 36 |
36 self.client.import_(['patch']) | 37 self.client.import_([b('patch')]) |
37 self.assertEquals(self.client.cat(['a']), '1\n') | 38 self.assertEquals(self.client.cat([b('a')]), b('1\n')) |