[PATCH 2 of 2 V2] tests: use absolute_import and print_function in filterpyflakes.py, genereate-working-copy-states.py, get-with-headers.py, hypothesishelper.py silenttestrunner.py
Robert Stanca
robert.stanca7 at gmail.com
Thu Mar 31 12:15:27 EDT 2016
# HG changeset patch
# User Robert Stanca <robert.stanca7 at gmail.com>
# Date 1459440811 -10800
# Thu Mar 31 19:13:31 2016 +0300
# Node ID bf276f26249e901c90b6183a549535999d915d30
# Parent 1aa23d597ac85bd8e53f92281a6251e58b9405d7
tests: use absolute_import and print_function in filterpyflakes.py, genereate-working-copy-states.py, get-with-headers.py, hypothesishelper.py silenttestrunner.py
Eliminate Python3 compatibility warnings
diff -r 1aa23d597ac8 -r bf276f26249e tests/filterpyflakes.py
--- a/tests/filterpyflakes.py Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/filterpyflakes.py Thu Mar 31 19:13:31 2016 +0300
@@ -2,7 +2,7 @@
# Filter output by pyflakes to control which warnings we check
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import re
import sys
@@ -54,8 +54,8 @@
for msgtype, line in sorted(lines, key=makekey):
sys.stdout.write(line)
-print
+print()
# self test of "undefined name" detection for other than 'memoryview'
if False:
- print undefinedname
+ print(undefinedname)
diff -r 1aa23d597ac8 -r bf276f26249e tests/generate-working-copy-states.py
--- a/tests/generate-working-copy-states.py Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/generate-working-copy-states.py Thu Mar 31 19:13:31 2016 +0300
@@ -29,7 +29,7 @@
# $ hg forget *_*_*-untracked
# $ rm *_*_missing-*
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import os
import sys
@@ -66,7 +66,7 @@
content = []
for filename, states in combinations:
if target == 'filelist':
- print filename
+ print(filename)
elif target == 'state':
if depth == 'wc':
# Make sure there is content so the file gets written and can be
@@ -75,7 +75,7 @@
else:
content.append((filename, states[int(depth) - 1]))
else:
- print >> sys.stderr, "unknown target:", target
+ print("unknown target:", target, file=sys.stderr)
sys.exit(1)
# write actual content
diff -r 1aa23d597ac8 -r bf276f26249e tests/get-with-headers.py
--- a/tests/get-with-headers.py Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/get-with-headers.py Thu Mar 31 19:13:31 2016 +0300
@@ -3,7 +3,7 @@
"""This does HTTP GET requests given a host:port and path and returns
a subset of the headers plus the body of the result."""
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import httplib
import json
@@ -41,15 +41,15 @@
conn = httplib.HTTPConnection(host)
conn.request("GET", '/' + path, None, headers)
response = conn.getresponse()
- print response.status, response.reason
+ print(response.status, response.reason)
if show[:1] == ['-']:
show = sorted(h for h, v in response.getheaders()
if h.lower() not in show)
for h in [h.lower() for h in show]:
if response.getheader(h, None) is not None:
- print "%s: %s" % (h, response.getheader(h))
+ print("%s: %s" % (h, response.getheader(h)))
if not headeronly:
- print
+ print()
data = response.read()
# Pretty print JSON. This also has the beneficial side-effect
@@ -60,7 +60,7 @@
data = json.loads(data)
lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
for line in lines:
- print line.rstrip()
+ print(line.rstrip())
else:
sys.stdout.write(data)
diff -r 1aa23d597ac8 -r bf276f26249e tests/hypothesishelpers.py
--- a/tests/hypothesishelpers.py Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/hypothesishelpers.py Thu Mar 31 19:13:31 2016 +0300
@@ -4,6 +4,7 @@
#
# For details see http://hypothesis.readthedocs.org
+from __future__ import absolute_import, print_function
import os
import sys
import traceback
diff -r 1aa23d597ac8 -r bf276f26249e tests/silenttestrunner.py
--- a/tests/silenttestrunner.py Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/silenttestrunner.py Thu Mar 31 19:13:31 2016 +0300
@@ -1,4 +1,7 @@
-import unittest, sys, os
+from __future__ import absolute_import, print_function
+import unittest
+import sys
+import os
def main(modulename):
'''run the tests found in module, printing nothing when all tests pass'''
@@ -8,12 +11,12 @@
suite.run(results)
if results.errors or results.failures:
for tc, exc in results.errors:
- print 'ERROR:', tc
- print
+ print('ERROR:', tc)
+ print()
sys.stdout.write(exc)
for tc, exc in results.failures:
- print 'FAIL:', tc
- print
+ print('FAIL:', tc)
+ print()
sys.stdout.write(exc)
sys.exit(1)
diff -r 1aa23d597ac8 -r bf276f26249e tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t Thu Mar 31 18:09:51 2016 +0300
+++ b/tests/test-check-py3-compat.t Thu Mar 31 19:13:31 2016 +0300
@@ -42,12 +42,7 @@
i18n/check-translation.py not using absolute_import
i18n/polib.py not using absolute_import
setup.py not using absolute_import
- tests/filterpyflakes.py requires print_function
- tests/generate-working-copy-states.py requires print_function
- tests/get-with-headers.py requires print_function
tests/heredoctest.py requires print_function
- tests/hypothesishelpers.py not using absolute_import
- tests/hypothesishelpers.py requires print_function
tests/killdaemons.py not using absolute_import
tests/md5sum.py not using absolute_import
tests/mockblackbox.py not using absolute_import
@@ -56,8 +51,6 @@
tests/readlink.py requires print_function
tests/revlog-formatv0.py not using absolute_import
tests/run-tests.py not using absolute_import
- tests/silenttestrunner.py not using absolute_import
- tests/silenttestrunner.py requires print_function
tests/sitecustomize.py not using absolute_import
tests/svn-safe-append.py not using absolute_import
tests/svnxml.py not using absolute_import
@@ -270,11 +263,7 @@
mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line 12)
mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line 10)
mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
- tests/filterpyflakes.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
- tests/generate-working-copy-states.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
- tests/get-with-headers.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
- tests/silenttestrunner.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
tests/test-batching.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
tests/test-bdiff.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
tests/test-context.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
More information about the Mercurial-devel
mailing list