88from test import test_support
99import cmd
1010import sys
11+ import trace
12+ import re
13+ from io import StringIO
1114
1215class samplecmdclass (cmd .Cmd ):
1316 """
@@ -95,9 +98,9 @@ class samplecmdclass(cmd.Cmd):
9598 <BLANKLINE>
9699
97100 Test for the function columnize():
98- >>> mycmd.columnize([str(i) for i in xrange (20)])
101+ >>> mycmd.columnize([str(i) for i in range (20)])
99102 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
100- >>> mycmd.columnize([str(i) for i in xrange (20)], 10)
103+ >>> mycmd.columnize([str(i) for i in range (20)], 10)
101104 0 7 14
102105 1 8 15
103106 2 9 16
@@ -131,36 +134,34 @@ class samplecmdclass(cmd.Cmd):
131134 """
132135
133136 def preloop (self ):
134- print "Hello from preloop"
137+ print ( "Hello from preloop" )
135138
136139 def postloop (self ):
137- print "Hello from postloop"
140+ print ( "Hello from postloop" )
138141
139142 def completedefault (self , * ignored ):
140- print "This is the completedefault methode"
141- return
143+ print ("This is the completedefault methode" )
142144
143145 def complete_command (self ):
144- print "complete command"
145- return
146+ print ("complete command" )
146147
147148 def do_shell (self ):
148149 pass
149150
150151 def do_add (self , s ):
151152 l = s .split ()
152153 if len (l ) != 2 :
153- print "*** invalid number of arguments"
154+ print ( "*** invalid number of arguments" )
154155 return
155156 try :
156157 l = [int (i ) for i in l ]
157158 except ValueError :
158- print "*** arguments should be numbers"
159+ print ( "*** arguments should be numbers" )
159160 return
160- print l [0 ]+ l [1 ]
161+ print ( l [0 ]+ l [1 ])
161162
162163 def help_add (self ):
163- print "help text for add"
164+ print ( "help text for add" )
164165 return
165166
166167 def do_exit (self , arg ):
@@ -170,13 +171,12 @@ def test_main(verbose=None):
170171 from test import test_support , test_cmd
171172 test_support .run_doctest (test_cmd , verbose )
172173
173- import trace , sys ,re ,StringIO
174174def test_coverage (coverdir ):
175175 tracer = trace .Trace (ignoredirs = [sys .prefix , sys .exec_prefix ,],
176176 trace = 0 , count = 1 )
177177 tracer .run ('reload(cmd);test_main()' )
178178 r = tracer .results ()
179- print "Writing coverage results..."
179+ print ( "Writing coverage results..." )
180180 r .write_results (show_missing = True , summary = True , coverdir = coverdir )
181181
182182if __name__ == "__main__" :
0 commit comments