diff tests/test-summary.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 3bbf6a3266f4
children c1b966866ed7
line wrap: on
line diff
--- a/tests/test-summary.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-summary.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,114 +1,115 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_summary(common.basetest):
     def test_empty(self):
-        d = {'parent' : [(-1, '000000000000', 'tip', None)],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0}
+        d = {b('parent') : [(-1, b('000000000000'), b('tip'), None)],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_basic(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_commit_dirty(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : False,
-             'update' : 0}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : False,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_update(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
         self.client.update(0)
 
-        d = {'parent' : [(0, node[:12], None, 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 1}
+        d = {b('parent') : [(0, node[:12], None, b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 1}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_remote(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
-        self.client.clone(dest='other')
+        self.client.clone(dest=b('other'))
         other = hglib.open('other')
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0,
-             'remote' : (0, 0, 0, 0)}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0,
+             b('remote') : (0, 0, 0, 0)}
 
         self.assertEquals(other.summary(remote=True), d)
 
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
-        d['remote'] = (1, 0, 0, 0)
+        d[b('remote')] = (1, 0, 0, 0)
         self.assertEquals(other.summary(remote=True), d)
 
-        self.client.bookmark('bm')
-        d['remote'] = (1, 1, 0, 0)
+        self.client.bookmark(b('bm'))
+        d[b('remote')] = (1, 1, 0, 0)
         self.assertEquals(other.summary(remote=True), d)
 
-        other.bookmark('bmother')
-        d['remote'] = (1, 1, 0, 1)
+        other.bookmark(b('bmother'))
+        d[b('remote')] = (1, 1, 0, 1)
         if self.client.version < (2, 0, 0):
-            d['parent'] = [(0, node[:12], 'tip bmother', 'first')]
+            d[b('parent')] = [(0, node[:12], b('tip bmother'), b('first'))]
         else:
-            d['bookmarks'] = '*bmother'
+            d[b('bookmarks')] = b('*bmother')
         self.assertEquals(other.summary(remote=True), d)
 
         self.append('other/a', 'a')
-        rev, node = other.commit('second in other')
+        rev, node = other.commit(b('second in other'))
 
-        d['remote'] = (1, 1, 1, 1)
+        d[b('remote')] = (1, 1, 1, 1)
         if self.client.version < (2, 0, 0):
-            tags = 'tip bmother'
+            tags = b('tip bmother')
         else:
-            tags = 'tip'
-        d['parent'] = [(1, node[:12], tags, 'second in other')]
+            tags = b('tip')
+        d[b('parent')] = [(1, node[:12], tags, b('second in other'))]
 
         self.assertEquals(other.summary(remote=True), d)
 
     def test_two_parents(self):
         self.append('a', 'a')
-        rev0, node = self.client.commit('first', addremove=True)
+        rev0, node = self.client.commit(b('first'), addremove=True)
 
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
+        rev1, node1 = self.client.commit(b('second'))
 
         self.client.update(rev0)
         self.append('b', 'a')
-        rev2, node2 = self.client.commit('third', addremove=True)
+        rev2, node2 = self.client.commit(b('third'), addremove=True)
 
         self.client.merge(rev1)
 
-        d = {'parent' : [(2, node2[:12], 'tip', 'third'),
-                         (1, node1[:12], None, 'second')],
-             'branch' : 'default',
-             'commit' : False,
-             'update' : 0}
+        d = {b('parent') : [(2, node2[:12], b('tip'), b('third')),
+                         (1, node1[:12], None, b('second'))],
+             b('branch') : b('default'),
+             b('commit') : False,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)