Mercurial > python-hglib
comparison tests/test-diff.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 | 1b47146a4a2c |
children | c1b966866ed7 |
comparison
equal
deleted
inserted
replaced
142:fe74d5599539 | 143:4359cabcb0cc |
---|---|
1 import common | 1 import common |
2 from hglib.util import b | |
2 | 3 |
3 class test_diff(common.basetest): | 4 class test_diff(common.basetest): |
4 def test_basic(self): | 5 def test_basic(self): |
5 self.append('a', 'a\n') | 6 self.append('a', 'a\n') |
6 self.client.add('a') | 7 self.client.add(b('a')) |
7 diff1 = """diff -r 000000000000 a | 8 diff1 = b("""diff -r 000000000000 a |
8 --- /dev/null | 9 --- /dev/null |
9 +++ b/a | 10 +++ b/a |
10 @@ -0,0 +1,1 @@ | 11 @@ -0,0 +1,1 @@ |
11 +a | 12 +a |
12 """ | 13 """) |
13 self.assertEquals(diff1, self.client.diff(nodates=True)) | 14 self.assertEquals(diff1, self.client.diff(nodates=True)) |
14 self.assertEquals(diff1, self.client.diff(['a'], nodates=True)) | 15 self.assertEquals(diff1, self.client.diff([b('a')], nodates=True)) |
15 rev0, node0 = self.client.commit('first') | 16 rev0, node0 = self.client.commit(b('first')) |
16 diff2 = """diff -r 000000000000 -r %s a | 17 diff2 = b("""diff -r 000000000000 -r """) + node0[:12] + b(""" a |
17 --- /dev/null | 18 --- /dev/null |
18 +++ b/a | 19 +++ b/a |
19 @@ -0,0 +1,1 @@ | 20 @@ -0,0 +1,1 @@ |
20 +a | 21 +a |
21 """ % node0[:12] | 22 """) |
22 self.assertEquals(diff2, self.client.diff(change=rev0, nodates=True)) | 23 self.assertEquals(diff2, self.client.diff(change=rev0, nodates=True)) |
23 self.append('a', 'a\n') | 24 self.append('a', 'a\n') |
24 rev1, node1 = self.client.commit('second') | 25 rev1, node1 = self.client.commit(b('second')) |
25 diff3 = """diff -r %s a | 26 diff3 = b("""diff -r """) + node0[:12] + b(""" a |
26 --- a/a | 27 --- a/a |
27 +++ b/a | 28 +++ b/a |
28 @@ -1,1 +1,2 @@ | 29 @@ -1,1 +1,2 @@ |
29 a | 30 a |
30 +a | 31 +a |
31 """ % node0[:12] | 32 """) |
32 self.assertEquals(diff3, self.client.diff(revs=[rev0], nodates=True)) | 33 self.assertEquals(diff3, self.client.diff(revs=[rev0], nodates=True)) |
33 diff4 = """diff -r %s -r %s a | 34 diff4 = b("""diff -r """) + node0[:12] + b(" -r ") + node1[:12] + b( |
35 """ a | |
34 --- a/a | 36 --- a/a |
35 +++ b/a | 37 +++ b/a |
36 @@ -1,1 +1,2 @@ | 38 @@ -1,1 +1,2 @@ |
37 a | 39 a |
38 +a | 40 +a |
39 """ % (node0[:12], node1[:12]) | 41 """) |
40 self.assertEquals(diff4, self.client.diff(revs=[rev0, rev1], | 42 self.assertEquals(diff4, self.client.diff(revs=[rev0, rev1], |
41 nodates=True)) | 43 nodates=True)) |
42 | 44 |
43 def test_basic_plain(self): | 45 def test_basic_plain(self): |
44 open('.hg/hgrc', 'a').write('[defaults]\ndiff=--git\n') | 46 open('.hg/hgrc', 'a').write('[defaults]\ndiff=--git\n') |