D270: tests: fix up test-run-tests failures on Python 3.6

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Wed Aug 9 10:18:15 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2e43c5cd57a7: tests: fix up test-run-tests failures on Python 3.6 (authored by durin42).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D270?vs=635&id=666

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-run-tests.py

CHANGE DETAILS

diff --git a/tests/test-run-tests.py b/tests/test-run-tests.py
--- a/tests/test-run-tests.py
+++ b/tests/test-run-tests.py
@@ -39,7 +39,7 @@
             and output.endswith(b'\n')), 'missing newline'
     assert not re.search(br'[^ \w\\/\r\n()*?]', expected + output), \
            b'single backslash or unknown char'
-    test = run_tests.TTest('test-run-test.t', '.', '.')
+    test = run_tests.TTest(b'test-run-test.t', b'.', b'.')
     match = test.linematch(expected, output)
     if isinstance(match, str):
         return 'special: ' + match
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -105,9 +105,13 @@
     PYTHON3 = True
     xrange = range # we use xrange in one place, and we'd rather not use range
     def _bytespath(p):
+        if p is None:
+            return p
         return p.encode('utf-8')
 
     def _strpath(p):
+        if p is None:
+            return p
         return p.decode('utf-8')
 
 elif sys.version_info >= (3, 0, 0):
@@ -1383,7 +1387,8 @@
                         else:
                             m = optline.match(el)
                             if m:
-                                conditions = [c for c in m.group(2).split(' ')]
+                                conditions = [
+                                    c for c in m.group(2).split(b' ')]
 
                                 if not self._hghave(conditions)[0]:
                                     optional.append(i)
@@ -1497,7 +1502,7 @@
             else:
                 m = optline.match(el)
                 if m:
-                    conditions = [c for c in m.group(2).split(' ')]
+                    conditions = [c for c in m.group(2).split(b' ')]
 
                     el = m.group(1) + b"\n"
                     if not self._hghave(conditions)[0]:



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


More information about the Mercurial-devel mailing list