本文整理汇总了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)
示例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)
示例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)
示例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}