mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Fixed merge accident. Next time I'm going to run the entire test suite ...
This commit is contained in:
parent
b9819954aa
commit
2137b6aa99
1 changed files with 14 additions and 14 deletions
|
@ -8,6 +8,9 @@ Original by Michael Schneider
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import cmd
|
import cmd
|
||||||
import sys
|
import sys
|
||||||
|
import trace
|
||||||
|
import re
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
class samplecmdclass(cmd.Cmd):
|
class samplecmdclass(cmd.Cmd):
|
||||||
"""
|
"""
|
||||||
|
@ -95,9 +98,9 @@ class samplecmdclass(cmd.Cmd):
|
||||||
<BLANKLINE>
|
<BLANKLINE>
|
||||||
|
|
||||||
Test for the function columnize():
|
Test for the function columnize():
|
||||||
>>> mycmd.columnize([str(i) for i in xrange(20)])
|
>>> mycmd.columnize([str(i) for i in range(20)])
|
||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
||||||
>>> mycmd.columnize([str(i) for i in xrange(20)], 10)
|
>>> mycmd.columnize([str(i) for i in range(20)], 10)
|
||||||
0 7 14
|
0 7 14
|
||||||
1 8 15
|
1 8 15
|
||||||
2 9 16
|
2 9 16
|
||||||
|
@ -131,18 +134,16 @@ class samplecmdclass(cmd.Cmd):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def preloop(self):
|
def preloop(self):
|
||||||
print "Hello from preloop"
|
print("Hello from preloop")
|
||||||
|
|
||||||
def postloop(self):
|
def postloop(self):
|
||||||
print "Hello from postloop"
|
print("Hello from postloop")
|
||||||
|
|
||||||
def completedefault(self, *ignored):
|
def completedefault(self, *ignored):
|
||||||
print "This is the completedefault methode"
|
print("This is the completedefault methode")
|
||||||
return
|
|
||||||
|
|
||||||
def complete_command(self):
|
def complete_command(self):
|
||||||
print "complete command"
|
print("complete command")
|
||||||
return
|
|
||||||
|
|
||||||
def do_shell(self):
|
def do_shell(self):
|
||||||
pass
|
pass
|
||||||
|
@ -150,17 +151,17 @@ class samplecmdclass(cmd.Cmd):
|
||||||
def do_add(self, s):
|
def do_add(self, s):
|
||||||
l = s.split()
|
l = s.split()
|
||||||
if len(l) != 2:
|
if len(l) != 2:
|
||||||
print "*** invalid number of arguments"
|
print("*** invalid number of arguments")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
l = [int(i) for i in l]
|
l = [int(i) for i in l]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "*** arguments should be numbers"
|
print("*** arguments should be numbers")
|
||||||
return
|
return
|
||||||
print l[0]+l[1]
|
print(l[0]+l[1])
|
||||||
|
|
||||||
def help_add(self):
|
def help_add(self):
|
||||||
print "help text for add"
|
print("help text for add")
|
||||||
return
|
return
|
||||||
|
|
||||||
def do_exit(self, arg):
|
def do_exit(self, arg):
|
||||||
|
@ -170,13 +171,12 @@ def test_main(verbose=None):
|
||||||
from test import test_support, test_cmd
|
from test import test_support, test_cmd
|
||||||
test_support.run_doctest(test_cmd, verbose)
|
test_support.run_doctest(test_cmd, verbose)
|
||||||
|
|
||||||
import trace, sys,re,StringIO
|
|
||||||
def test_coverage(coverdir):
|
def test_coverage(coverdir):
|
||||||
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
|
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
|
||||||
trace=0, count=1)
|
trace=0, count=1)
|
||||||
tracer.run('reload(cmd);test_main()')
|
tracer.run('reload(cmd);test_main()')
|
||||||
r=tracer.results()
|
r=tracer.results()
|
||||||
print "Writing coverage results..."
|
print("Writing coverage results...")
|
||||||
r.write_results(show_missing=True, summary=True, coverdir=coverdir)
|
r.write_results(show_missing=True, summary=True, coverdir=coverdir)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue