Patchwork [1,of,5] test-manifest: create constant for empty manifest

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 1, 2015, 5:34 p.m.
Message ID <6728e02f14c2873c043c.1427909686@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8421/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 1, 2015, 5:34 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1427838365 25200
#      Tue Mar 31 14:46:05 2015 -0700
# Node ID 6728e02f14c2873c043cc2400f549f8a455221f5
# Parent  1b97cc5d2272c272961cc3e1d738e521af012a40
test-manifest: create constant for empty manifest

For symmetry with manifest v2, once we add that, let's extract a
constant for the empty v1 manifest.

Patch

diff -r 1b97cc5d2272 -r 6728e02f14c2 tests/test-manifest.py
--- a/tests/test-manifest.py	Tue Mar 31 18:09:21 2015 -0500
+++ b/tests/test-manifest.py	Tue Mar 31 14:46:05 2015 -0700
@@ -7,6 +7,8 @@ 
 from mercurial import manifest as manifestmod
 from mercurial import match as matchmod
 
+EMTPY_MANIFEST = ''
+
 HASH_1 = '1' * 40
 HASH_2 = 'f' * 40
 HASH_3 = '1234567890abcdef0987654321deadbeef0fcafe'
@@ -68,7 +70,7 @@ 
         self.assert_(thing in container, msg)
 
     def testEmptyManifest(self):
-        m = parsemanifest('')
+        m = parsemanifest(EMTPY_MANIFEST)
         self.assertEqual(0, len(m))
         self.assertEqual([], list(m))
 
@@ -84,7 +86,7 @@ 
     def testSetItem(self):
         want = binascii.unhexlify(HASH_1)
 
-        m = parsemanifest('')
+        m = parsemanifest(EMTPY_MANIFEST)
         m['a'] = want
         self.assertIn('a', m)
         self.assertEqual(want, m['a'])
@@ -99,7 +101,7 @@ 
     def testSetFlag(self):
         want = 'x'
 
-        m = parsemanifest('')
+        m = parsemanifest(EMTPY_MANIFEST)
         # first add a file; a file-less flag makes no sense
         m['a'] = binascii.unhexlify(HASH_1)
         m.setflag('a', want)
@@ -214,14 +216,14 @@ 
             'foo': (MISSING, (binascii.unhexlify(HASH_3), 'x')),
             'z-only-in-left': (MISSING, (binascii.unhexlify(HASH_1), '')),
             }
-        self.assertEqual(want, parsemanifest('').diff(left))
+        self.assertEqual(want, parsemanifest(EMTPY_MANIFEST).diff(left))
 
         want = {
             'bar/baz/qux.py': ((binascii.unhexlify(HASH_2), 'l'), MISSING),
             'foo': ((binascii.unhexlify(HASH_3), 'x'), MISSING),
             'z-only-in-left': ((binascii.unhexlify(HASH_1), ''), MISSING),
             }
-        self.assertEqual(want, left.diff(parsemanifest('')))
+        self.assertEqual(want, left.diff(parsemanifest(EMTPY_MANIFEST)))
         copy = right.copy()
         del copy['z-only-in-right']
         del right['foo']