当前位置: 首页>>代码示例>>Python>>正文


Python MockTurtle.get_all_reports方法代码示例

本文整理汇总了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)
开发者ID:dgentry,项目名称:myDotfiles,代码行数:35,代码来源:code_tracer.py

示例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)
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:18,代码来源:mock_turtle_test.py

示例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)
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:49,代码来源:mock_turtle_test.py

示例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())
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:6,代码来源:code_tracer.py

示例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
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:33,代码来源:code_tracer.py


注:本文中的mock_turtle.MockTurtle.get_all_reports方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。