本文整理汇总了Python中mock_turtle.MockTurtle.get_all_reports方法的典型用法代码示例。如果您正苦于以下问题:Python MockTurtle.get_all_reports方法的具体用法?Python MockTurtle.get_all_reports怎么用?Python MockTurtle.get_all_reports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock_turtle.MockTurtle
的用法示例。
在下文中一共展示了MockTurtle.get_all_reports方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import get_all_reports [as 别名]
def main():
parser = argparse.ArgumentParser(description='Trace Python code.')
parser.add_argument('-c',
'--canvas',
action='store_true',
help='Should canvas commands be printed?')
parser.add_argument('-x',
'--width',
type=int,
default=800,
help='width of the canvas in pixels')
parser.add_argument('-y',
'--height',
type=int,
default=600,
help='height of the canvas in pixels')
parser.add_argument('-m',
'--module',
help='install traced code as a module with this name')
args = parser.parse_args()
code = sys.stdin.read()
canvas = Canvas(args.width, args.height)
tracer = CodeTracer(canvas)
tracer.max_width = 200000
code_report = tracer.trace_code(code, module_name=args.module)
turtle_report = MockTurtle.get_all_reports()
if turtle_report and args.canvas:
print('start_canvas')
print('\n'.join(turtle_report))
print('end_canvas')
print('.')
print(code_report)
示例2: test_monkey_patch_anonymous_turtle
# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import get_all_reports [as 别名]
def test_monkey_patch_anonymous_turtle(self):
MockTurtle.monkey_patch()
expected_report = """\
create_line
0
0
100
0
fill='black'
pensize=1
"""
turtle.fd(100)
report = MockTurtle.get_all_reports()
self.assertEqual(expected_report.splitlines(), report)
示例3: test_monkey_patch_multiple_turtles
# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import get_all_reports [as 别名]
def test_monkey_patch_multiple_turtles(self):
MockTurtle.monkey_patch()
expected_report = """\
create_line
0
0
100
0
fill='black'
pensize=1
create_line
100
0
100
100
fill='black'
pensize=1
create_line
0
0
100
0
fill='black'
pensize=1
create_line
100
0
100
-100
fill='black'
pensize=1
"""
t1 = turtle.Turtle()
t1.begin_fill()
t1.fd(100)
t1.right(90)
t1.fd(100)
t2 = turtle.Turtle()
t2.begin_fill()
t2.fd(100)
t2.left(90)
t2.fd(100)
report = MockTurtle.get_all_reports()
self.maxDiff = None
self.assertEqual(expected_report.splitlines(), report)
示例4: trace_turtle
# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import get_all_reports [as 别名]
def trace_turtle(self, source):
exec(source, self.environment, self.environment)
return '\n'.join(MockTurtle.get_all_reports())
示例5: Canvas
# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import get_all_reports [as 别名]
parser.add_argument('-y',
'--height',
type=int,
default=600,
help='height of the canvas in pixels')
parser.add_argument('-m',
'--module',
help='install traced code as a module with this name')
args = parser.parse_args()
code = sys.stdin.read()
canvas = Canvas(args.width, args.height)
tracer = CodeTracer(canvas)
tracer.max_width = 200000
code_report = tracer.trace_code(code, module_name=args.module)
turtle_report = MockTurtle.get_all_reports()
if turtle_report and args.canvas:
print('start_canvas')
print('\n'.join(turtle_report))
print('end_canvas')
print('.')
print(code_report)
elif __name__ == '__live_coding__':
import unittest
def test_something(self):
# SETUP
code = """\
a = [1, 2, [3, 4]]
a[0] += 1