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


Python MockTurtle.monkey_patch方法代码示例

本文整理汇总了Python中mock_turtle.MockTurtle.monkey_patch方法的典型用法代码示例。如果您正苦于以下问题:Python MockTurtle.monkey_patch方法的具体用法?Python MockTurtle.monkey_patch怎么用?Python MockTurtle.monkey_patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock_turtle.MockTurtle的用法示例。


在下文中一共展示了MockTurtle.monkey_patch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bounds_after_monkey_patch

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import monkey_patch [as 别名]
    def test_bounds_after_monkey_patch(self):
        # SETUP
        expected_width = 300
        expected_height = 200

        # EXEC
        MockTurtle.monkey_patch(canvas=Canvas(expected_width, expected_height))
        width = turtle.window_width()
        height = turtle.window_height()

        # VERIFY
        self.assertEqual(expected_width, width)
        self.assertEqual(expected_height, height)
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:15,代码来源:mock_turtle_test.py

示例2: test_monkey_patch_anonymous_turtle

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import monkey_patch [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 monkey_patch [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: __init__

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import monkey_patch [as 别名]
 def __init__(self, canvas=None):
     self.message_limit = 10000
     self.max_width = None
     self.keepalive = False
     MockTurtle.monkey_patch(canvas)
     self.environment = {'__name__': SCOPE_NAME}
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:8,代码来源:code_tracer.py


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