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


Python MockTurtle.fd方法代码示例

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


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

示例1: test_forgotten_end_fill

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_forgotten_end_fill(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#ff0000'
    pensize=1
create_line
    100
    0
    100
    100
    fill='#ff0000'
    pensize=1
"""
        
        # EXEC
        t = MockTurtle()
        t.color('red', 'blue')
        t.begin_fill()
        for _ in range(2):
            t.fd(100)
            t.right(90)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:Amirus,项目名称:live-py-plugin,代码行数:32,代码来源:mock_turtle_test.py

示例2: test_bgcolor

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_bgcolor(self):
        # SETUP
        expected_report = """\
bgcolor
    fill='#00ff00'
    outline=''
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.fd(100)
        color1 = t.screen.bgcolor()
        t.screen.bgcolor('green')
        color2 = t.screen.bgcolor()
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
        self.assertEqual('white', color1)
        self.assertEqual('green', color2)
开发者ID:donkirkby,项目名称:live-py-plugin,代码行数:28,代码来源:test_mock_turtle.py

示例3: test_write

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_write(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1
create_text
    100
    0
    anchor='sw'
    fill='black'
    font=('Arial', 8, 'normal')
    text='Bob'
"""
        
        # EXEC
        t = MockTurtle()
        t.fd(100)
        t.write('Bob')
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:Amirus,项目名称:live-py-plugin,代码行数:29,代码来源:mock_turtle_test.py

示例4: test_scale

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_scale(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1
create_line
    100
    0
    100
    150
    fill='black'
    pensize=1
"""

        
        # EXEC
        t = MockTurtle(canvas=Canvas())
        t.screen.xscale = 100.0
        t.screen.yscale = 50
        t.fd(1)
        t.right(90)
        t.fd(3)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:Amirus,项目名称:live-py-plugin,代码行数:33,代码来源:mock_turtle_test.py

示例5: test_repr

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
 def test_repr(self):
     # SETUP
     expected_text = "MockTurtle(100, 0, 10)"
     
     # EXEC
     t = MockTurtle(25, 0, -7)
     t.left(7)
     t.fd(75)
     t.left(10)
     text = repr(t)
     
     # VERIFY
     self.assertEqual(expected_text, text)
开发者ID:Amirus,项目名称:live-py-plugin,代码行数:15,代码来源:mock_turtle_test.py

示例6: test_forward

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_forward(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'"""
        
        # EXEC
        t = MockTurtle()
        t.fd(100)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:rohitkoul,项目名称:live-py-plugin,代码行数:19,代码来源:mock_turtle_test.py

示例7: test_offset

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_offset(self):
        # SETUP
        expected_report = """\
create_line
    400
    300
    500
    300
    fill='black'"""

        
        # EXEC
        t = MockTurtle(canvas=Canvas(800, 600))
        t.fd(100)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:rohitkoul,项目名称:live-py-plugin,代码行数:20,代码来源:mock_turtle_test.py

示例8: test_color

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_color(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#ff0080'"""
        
        # EXEC
        t = MockTurtle()
        t.color(1.0, 0.0, 0.5)
        t.fd(100)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:rohitkoul,项目名称:live-py-plugin,代码行数:20,代码来源:mock_turtle_test.py

示例9: test_pen_dict

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_pen_dict(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#0000ff'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.pen(pencolor=(0, 0, 1.0))
        t.fd(100)
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:donkirkby,项目名称:live-py-plugin,代码行数:21,代码来源:test_mock_turtle.py

示例10: test_color_bad_range

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_color_bad_range(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#000000'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.color(1.0, 0.0, 1.5)  # Over 1.0 not allowed, fails to black.
        t.fd(100)
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:donkirkby,项目名称:live-py-plugin,代码行数:21,代码来源:test_mock_turtle.py

示例11: test_color_bad

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_color_bad(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#000000'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.color((1.0, 0.0))  # Only two numbers, fails to black.
        t.fd(100)
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:donkirkby,项目名称:live-py-plugin,代码行数:21,代码来源:test_mock_turtle.py

示例12: test_color_name

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_color_name(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='#0000ff'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.color('blue')
        t.fd(100)
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:donkirkby,项目名称:live-py-plugin,代码行数:21,代码来源:test_mock_turtle.py

示例13: test_penup

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_penup(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1
create_line
    150
    0
    350
    0
    fill='black'
    pensize=1
"""
        
        # EXEC
        t = MockTurtle()
        t.fd(100)
        t.penup()
        t.fd(50)
        t.pendown()
        t.fd(200)
        report = t.report
        
        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:Amirus,项目名称:live-py-plugin,代码行数:32,代码来源:mock_turtle_test.py

示例14: test_offset_with_scale

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_offset_with_scale(self):
        """ The offset is applied BEFORE the scale. """

        # SETUP
        expected_report = """\
create_line
    400
    300
    500
    300
    fill='black'
    pensize=1
"""

        # EXEC
        t = MockTurtle(canvas=Canvas(800, 600))
        t.screen.xscale = 100
        t.fd(1)
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:ajinkyakulkarni,项目名称:live-py-plugin,代码行数:24,代码来源:mock_turtle_test.py

示例15: test_fill

# 需要导入模块: from mock_turtle import MockTurtle [as 别名]
# 或者: from mock_turtle.MockTurtle import fd [as 别名]
    def test_fill(self):
        # SETUP
        expected_report = """\
create_polygon
    0
    0
    100
    0
    100
    100
    fill='#0000ff'
    outline=''
create_line
    0
    0
    100
    0
    fill='#ff0000'
    pensize=1
create_line
    100
    0
    100
    100
    fill='#ff0000'
    pensize=1"""

        # EXEC
        t = MockTurtle()
        t.color("red", "blue")
        t.begin_fill()
        for _ in range(2):
            t.fd(100)
            t.right(90)
        t.end_fill()
        report = t.report

        # VERIFY
        self.assertEqual(expected_report.splitlines(), report)
开发者ID:emacsmirror,项目名称:live-py-mode,代码行数:41,代码来源:mock_turtle_test.py


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