Patchwork D3833: py3: make tests/test-diff-antipatience.t work with python 3

login
register
mail settings
Submitter phabricator
Date June 25, 2018, 8:45 p.m.
Message ID <differential-rev-PHID-DREV-53z3hacvjbww5leiryug-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32426/
State Superseded
Headers show

Comments

phabricator - June 25, 2018, 8:45 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  On python3, if we do list(b'abcd'), we get [97, 98, 99, 100]. So this patch does
  the list() operation on unicodes and then convert things to bytes.
  
  This also adds `and None` to suppress return values of .write() calls.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-diff-antipatience.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-diff-antipatience.t b/tests/test-diff-antipatience.t
--- a/tests/test-diff-antipatience.t
+++ b/tests/test-diff-antipatience.t
@@ -11,9 +11,9 @@ 
 Test case that makes use of the weakness of patience diff algorithm
 
   $ hg init
-  >>> open('a', 'wb').write(b'\n'.join(list(b'a' + b'x' * 10 + b'u' + b'x' * 30 + b'a\n')))
+  >>> open('a', 'wb').write(('\n'.join(list('a' + 'x' * 10 + 'u' + 'x' * 30 + 'a\n'))).encode('ascii')) and None
   $ hg commit -m 1 -A a
-  >>> open('a', 'wb').write(b'\n'.join(list(b'b' + b'x' * 30 + b'u' + b'x' * 10 + b'b\n')))
+  >>> open('a', 'wb').write(('\n'.join(list('b' + 'x' * 30 + 'u' + 'x' * 10 + 'b\n'))).encode('ascii')) and None
 #if xdiff
   $ hg diff
   diff -r f0aeecb49805 a
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -88,6 +88,7 @@ 
 test-debugindexdot.t
 test-debugrename.t
 test-default-push.t
+test-diff-antipatience.t
 test-diff-binary-file.t
 test-diff-change.t
 test-diff-copy-depth.t