D3514: tests: port test-lfs-pointer.py to Python 3

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue May 8 16:46:39 EDT 2018


durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The weird bit here is having to import /something/ from Mercurial
  before we touch hgext.* so that the module loader gets
  initialized. That's probably a bug we should explore at some point?

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-lfs-pointer.py

CHANGE DETAILS

diff --git a/tests/test-lfs-pointer.py b/tests/test-lfs-pointer.py
--- a/tests/test-lfs-pointer.py
+++ b/tests/test-lfs-pointer.py
@@ -6,36 +6,40 @@
 # make it runnable using python directly without run-tests.py
 sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
 
+# Import something from Mercurial, so the module loader gets initialized.
+from mercurial import pycompat
+del pycompat  # unused for now
+
 from hgext.lfs import pointer
 
 def tryparse(text):
     r = {}
     try:
         r = pointer.deserialize(text)
         print('ok')
     except Exception as ex:
-        print(ex)
+        print((b'%s' % ex).decode('ascii'))
     if r:
         text2 = r.serialize()
         if text2 != text:
             print('reconstructed text differs')
     return r
 
-t = ('version https://git-lfs.github.com/spec/v1\n'
-     'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
-     '258daaa5e2ca24d17e2393\n'
-     'size 12345\n'
-     'x-foo extra-information\n')
+t = (b'version https://git-lfs.github.com/spec/v1\n'
+     b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
+     b'258daaa5e2ca24d17e2393\n'
+     b'size 12345\n'
+     b'x-foo extra-information\n')
 
-tryparse('')
+tryparse(b'')
 tryparse(t)
-tryparse(t.replace('git-lfs', 'unknown'))
-tryparse(t.replace('v1\n', 'v1\n\n'))
-tryparse(t.replace('sha256', 'ahs256'))
-tryparse(t.replace('sha256:', ''))
-tryparse(t.replace('12345', '0x12345'))
-tryparse(t.replace('extra-information', 'extra\0information'))
-tryparse(t.replace('extra-information', 'extra\ninformation'))
-tryparse(t.replace('x-foo', 'x_foo'))
-tryparse(t.replace('oid', 'blobid'))
-tryparse(t.replace('size', 'size-bytes').replace('oid', 'object-id'))
+tryparse(t.replace(b'git-lfs', b'unknown'))
+tryparse(t.replace(b'v1\n', b'v1\n\n'))
+tryparse(t.replace(b'sha256', b'ahs256'))
+tryparse(t.replace(b'sha256:', b''))
+tryparse(t.replace(b'12345', b'0x12345'))
+tryparse(t.replace(b'extra-information', b'extra\0information'))
+tryparse(t.replace(b'extra-information', b'extra\ninformation'))
+tryparse(t.replace(b'x-foo', b'x_foo'))
+tryparse(t.replace(b'oid', b'blobid'))
+tryparse(t.replace(b'size', b'size-bytes').replace(b'oid', b'object-id'))
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -225,6 +225,7 @@
 test-largefiles-update.t
 test-largefiles.t
 test-lfs-largefiles.t
+test-lfs-pointer.py
 test-linerange.py
 test-locate.t
 test-lock-badness.t



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


More information about the Mercurial-devel mailing list