Patchwork D5500: tests: add lots of b prefix goo to test-fastannotate-revmap.py

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2019, 10:57 a.m.
Message ID <1844871b5fc584a588681584b296928f@localhost.localdomain>
Download mbox | patch
Permalink /patch/37519/
State Not Applicable
Headers show

Comments

phabricator - Jan. 7, 2019, 10:57 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0fea133780bf: tests: add lots of b prefix goo to test-fastannotate-revmap.py (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5500?vs=13022&id=13041

REVISION DETAIL
  https://phab.mercurial-scm.org/D5500

AFFECTED FILES
  tests/test-fastannotate-revmap.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/tests/test-fastannotate-revmap.py b/tests/test-fastannotate-revmap.py
--- a/tests/test-fastannotate-revmap.py
+++ b/tests/test-fastannotate-revmap.py
@@ -35,7 +35,8 @@ 
         ensure(rm.rev2hsh(i) is None)
     ensure(rm.hsh2rev(b'\0' * 20) is None)
 
-    paths = ['', 'a', None, 'b', 'b', 'c', 'c', None, 'a', 'b', 'a', 'a']
+    paths = [
+        b'', b'a', None, b'b', b'b', b'c', b'c', None, b'a', b'b', b'a', b'a']
     for i in xrange(1, 5):
         ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i]) == i)
 
@@ -88,7 +89,7 @@ 
     path = gettemppath()
 
     # incorrect header
-    with open(path, 'w') as f:
+    with open(path, 'wb') as f:
         f.write(b'NOT A VALID HEADER')
     try:
         revmap.revmap(path)
@@ -106,17 +107,17 @@ 
 
     # corrupt the file by appending a byte
     size = os.stat(path).st_size
-    with open(path, 'a') as f:
-        f.write('\xff')
+    with open(path, 'ab') as f:
+        f.write(b'\xff')
     try:
         revmap.revmap(path)
         ensure(False)
     except error.CorruptedFileError:
         pass
 
     # corrupt the file by removing the last byte
     ensure(size > 0)
-    with open(path, 'w') as f:
+    with open(path, 'wb') as f:
         f.truncate(size - 1)
     try:
         revmap.revmap(path)
@@ -130,7 +131,8 @@ 
     path = gettemppath()
     rm = revmap.revmap(path)
     for i in xrange(1, 10):
-        ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=str(i // 3)) == i)
+        ensure(rm.append(genhsh(i),
+                         sidebranch=(i & 1), path=(b'%d' % (i // 3))) == i)
     rm.flush()
 
     # copy rm to rm2
@@ -174,19 +176,19 @@ 
     # "contains" checks paths
     rm = revmap.revmap()
     for i in xrange(1, 5):
-        ensure(rm.append(genhsh(i), path=str(i // 2)) == i)
+        ensure(rm.append(genhsh(i), path=(b'%d' % (i // 2))) == i)
     for i in xrange(1, 5):
-        ensure(fakefctx(genhsh(i), path=str(i // 2)) in rm)
-        ensure(fakefctx(genhsh(i), path='a') not in rm)
+        ensure(fakefctx(genhsh(i), path=(b'%d' % (i // 2))) in rm)
+        ensure(fakefctx(genhsh(i), path=b'a') not in rm)
 
 def testlastnode():
     path = gettemppath()
     ensure(revmap.getlastnode(path) is None)
     rm = revmap.revmap(path)
     ensure(revmap.getlastnode(path) is None)
     for i in xrange(1, 10):
         hsh = genhsh(i)
-        rm.append(hsh, path=str(i // 2), flush=True)
+        rm.append(hsh, path=(b'%d' % (i // 2)), flush=True)
         ensure(revmap.getlastnode(path) == hsh)
         rm2 = revmap.revmap(path)
         ensure(rm2.rev2hsh(rm2.maxrev) == hsh)