diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 654f59030..be07c7b24 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -24,6 +24,7 @@ itself from the command line. There are two ways of running this script: #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- +from __future__ import print_function # Stdlib import glob @@ -423,7 +424,7 @@ class IPTester(object): for pid in self.pids: try: - print 'Cleaning stale PID:', pid + print('Cleaning stale PID:', pid) os.kill(pid, signal.SIGKILL) except OSError: # This is just a best effort, if we fail or the process was @@ -527,8 +528,8 @@ def run_iptestall(): t_start = time.time() try: for (name, runner) in runners: - print '*'*70 - print 'IPython test group:',name + print('*'*70) + print('IPython test group:',name) res = runner.run() if res: failed.append( (name, runner) ) @@ -539,26 +540,26 @@ def run_iptestall(): nrunners = len(runners) nfail = len(failed) # summarize results - print - print '*'*70 - print 'Test suite completed for system with the following information:' - print report() - print 'Ran %s test groups in %.3fs' % (nrunners, t_tests) - print - print 'Status:' + print() + print('*'*70) + print('Test suite completed for system with the following information:') + print(report()) + print('Ran %s test groups in %.3fs' % (nrunners, t_tests)) + print() + print('Status:') if not failed: - print 'OK' + print('OK') else: # If anything went wrong, point out what command to rerun manually to # see the actual errors and individual summary - print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners) + print('ERROR - %s out of %s test groups failed.' % (nfail, nrunners)) for name, failed_runner in failed: - print '-'*40 - print 'Runner failed:',name - print 'You may wish to rerun this one individually, with:' + print('-'*40) + print('Runner failed:',name) + print('You may wish to rerun this one individually, with:') failed_call_args = [py3compat.cast_unicode(x) for x in failed_runner.call_args] - print u' '.join(failed_call_args) - print + print(u' '.join(failed_call_args)) + print() # Ensure that our exit code indicates failure sys.exit(1) diff --git a/IPython/utils/tests/test_io.py b/IPython/utils/tests/test_io.py index 71244d3cf..ba169ba21 100644 --- a/IPython/utils/tests/test_io.py +++ b/IPython/utils/tests/test_io.py @@ -11,6 +11,7 @@ #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- +from __future__ import print_function import sys @@ -33,7 +34,7 @@ def test_tee_simple(): chan = StringIO() text = 'Hello' tee = Tee(chan, channel='stdout') - print >> chan, text + print(text, file=chan) nt.assert_equal(chan.getvalue(), text+"\n") @@ -48,7 +49,7 @@ class TeeTestCase(dec.ParametricTestCase): setattr(sys, channel, trap) tee = Tee(chan, channel=channel) - print >> chan, text, + print(text, end='', file=chan) setattr(sys, channel, std_ori) trap_val = trap.getvalue() nt.assert_equals(chan.getvalue(), text) @@ -78,8 +79,8 @@ def test_capture_output(): """capture_output() context works""" with capture_output() as io: - print 'hi, stdout' - print >> sys.stderr, 'hi, stderr' + print('hi, stdout') + print('hi, stderr', file=sys.stderr) nt.assert_equals(io.stdout, 'hi, stdout\n') nt.assert_equals(io.stderr, 'hi, stderr\n')