Patchwork [5,of,5,V2] tests: use absolute_import, print_function in multiple files

login
register
mail settings
Submitter roby roby
Date April 1, 2016, 2:12 a.m.
Message ID <242ecc170c23cc28823b.1459476727@roby>
Download mbox | patch
Permalink /patch/14217/
State Changes Requested
Headers show

Comments

roby roby - April 1, 2016, 2:12 a.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@gmail.com>
# Date 1459473357 -10800
#      Fri Apr 01 04:15:57 2016 +0300
# Node ID 242ecc170c23cc28823be94a07413ed0de6c799a
# Parent  254e1fc8ec44b23af5e51cf971fdee5702065ff4
tests: use absolute_import, print_function in multiple files

Eliminate Python3 compatibility warnings

Patch

diff -r 254e1fc8ec44 -r 242ecc170c23 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Fri Apr 01 03:26:02 2016 +0300
+++ b/tests/test-check-py3-compat.t	Fri Apr 01 04:15:57 2016 +0300
@@ -74,12 +74,8 @@ 
   tests/test-manifest.py not using absolute_import
   tests/test-pathencode.py not using absolute_import
   tests/test-pathencode.py requires print_function
-  tests/test-revlog-ancestry.py not using absolute_import
-  tests/test-revlog-ancestry.py requires print_function
   tests/test-run-tests.py not using absolute_import
   tests/test-simplemerge.py not using absolute_import
-  tests/test-status-inprocess.py not using absolute_import
-  tests/test-status-inprocess.py requires print_function
   tests/test-symlink-os-yes-fs-no.py not using absolute_import
   tests/test-trusted.py not using absolute_import
   tests/test-trusted.py requires print_function
@@ -258,8 +254,6 @@ 
   tests/test-ancestor.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-lrucachedict.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
-  tests/test-revlog-ancestry.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
-  tests/test-status-inprocess.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-trusted.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-ui-color.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-ui-config.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
diff -r 254e1fc8ec44 -r 242ecc170c23 tests/test-revlog-ancestry.py
--- a/tests/test-revlog-ancestry.py	Fri Apr 01 03:26:02 2016 +0300
+++ b/tests/test-revlog-ancestry.py	Fri Apr 01 04:15:57 2016 +0300
@@ -1,5 +1,10 @@ 
+from __future__ import absolute_import, print_function
 import os
-from mercurial import hg, ui, merge
+from mercurial import (
+    hg,
+    ui,
+    merge,
+)
 
 u = ui.ui()
 
@@ -46,39 +51,38 @@ 
     addcommit("I", 8)
 
     # Ancestors
-    print 'Ancestors of 5'
+    print('Ancestors of 5')
     for r in repo.changelog.ancestors([5]):
-        print r,
+        print(r, end=' ')
 
-    print '\nAncestors of 6 and 5'
+    print('\nAncestors of 6 and 5')
     for r in repo.changelog.ancestors([6, 5]):
-        print r,
+        print(r, end=' ')
 
-    print '\nAncestors of 5 and 4'
+    print('\nAncestors of 5 and 4')
     for r in repo.changelog.ancestors([5, 4]):
-        print r,
+        print(r, end=' ')
 
-    print '\nAncestors of 7, stop at 6'
+    print('\nAncestors of 7, stop at 6')
     for r in repo.changelog.ancestors([7], 6):
-        print r,
+        print(r, end=' ')
 
-    print '\nAncestors of 7, including revs'
+    print('\nAncestors of 7, including revs')
     for r in repo.changelog.ancestors([7], inclusive=True):
-        print r,
+        print(r, end=' ')
 
-    print '\nAncestors of 7, 5 and 3, including revs'
+    print('\nAncestors of 7, 5 and 3, including revs')
     for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
-        print r,
+        print(r, end=' ')
 
     # Descendants
-    print '\n\nDescendants of 5'
+    print('\n\nDescendants of 5')
     for r in repo.changelog.descendants([5]):
-        print r,
+        print(r, end=' ')
 
-    print '\nDescendants of 5 and 3'
+    print('\nDescendants of 5 and 3')
     for r in repo.changelog.descendants([5, 3]):
-        print r,
+        print(r, end=' ')
 
-    print '\nDescendants of 5 and 4'
-    for r in repo.changelog.descendants([5, 4]):
-        print r,
+    print('\nDescendants of 5 and 4')
+    print(*repo.changelog.descendants([5, 4]), sep=' ')
diff -r 254e1fc8ec44 -r 242ecc170c23 tests/test-status-inprocess.py
--- a/tests/test-status-inprocess.py	Fri Apr 01 03:26:02 2016 +0300
+++ b/tests/test-status-inprocess.py	Fri Apr 01 04:15:57 2016 +0300
@@ -1,11 +1,20 @@ 
 #!/usr/bin/python
-from mercurial.ui import ui
-from mercurial.localrepo import localrepository
-from mercurial.commands import add, commit, status
+from __future__ import absolute_import, print_function
+from mercurial.ui import (
+    ui,
+ )
+from mercurial.localrepo import (
+    localrepository,
+)
+from mercurial.commands import (
+    add,
+    commit,
+    status,
+)
 
 u = ui()
 
-print '% creating repo'
+print('% creating repo')
 repo = localrepository(u, '.', create=True)
 
 f = open('test.py', 'w')
@@ -14,13 +23,13 @@ 
 finally:
     f.close
 
-print '% add and commit'
+print('% add and commit')
 add(u, repo, 'test.py')
 commit(u, repo, message='*')
 status(u, repo, clean=True)
 
 
-print '% change'
+print('% change')
 f = open('test.py', 'w')
 try:
     f.write('bar\n')