Here are the examples of the python api mock_turtle.MockTurtle taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
17 Examples
3
Example 1
def test_forward(self):
# SETUP
expected_report = """\
create_line
0
0
100
0
fill='black'
pensize=1
"""
# EXEC
t = MockTurtle()
t.fd(100)
report = t.report
# VERIFY
self.assertEqual(expected_report.splitlines(), report)
3
Example 2
Project: live-py-plugin Source File: mock_turtle_test.py
def test_bounds(self):
# SETUP
expected_width = 800
expected_height = 600
# EXEC
t = MockTurtle(canvas=Canvas(expected_width, expected_height))
width = t.window_width()
height = t.window_height()
# VERIFY
self.assertEqual(expected_width, width)
self.assertEqual(expected_height, height)
3
Example 3
Project: live-py-plugin Source File: mock_turtle_test.py
def test_offset(self):
# SETUP
expected_report = """\
create_line
400
300
500
300
fill='black'
pensize=1
"""
# EXEC
t = MockTurtle(canvas=Canvas(800, 600))
t.fd(100)
report = t.report
# VERIFY
self.assertEqual(expected_report.splitlines(), report)
3
Example 4
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)
3
Example 5
def test_color(self):
# SETUP
expected_report = """\
create_line
0
0
100
0
fill='#ff0080'
pensize=1"""
# EXEC
t = MockTurtle()
t.color(1.0, 0.0, 0.5)
t.fd(100)
report = t.report
# VERIFY
self.assertEqual(expected_report.splitlines(), report)
3
Example 6
Project: live-py-plugin Source File: mock_turtle_test.py
def test_get_color_names(self):
t = MockTurtle()
t.color('blue')
color = t.color()
self.assertIn(color, (('blue', 'blue'), ('blue1', 'blue1')))
3
Example 7
Project: live-py-plugin Source File: mock_turtle_test.py
def test_get_color_rgb(self):
t = MockTurtle()
expected_color = (1.0, 0.0, 0.5)
t.color(expected_color)
color = t.color()
self.assertEqual((expected_color, expected_color), color)
0
Example 8
def test_right(self):
# SETUP
expected_report = """\
create_line
0
0
0
100
fill='black'
pensize=1
"""
# EXEC
t = MockTurtle()
t.right(90)
t.fd(100)
report = t.report
# VERIFY
self.assertEqual(expected_report.splitlines(), report)
0
Example 9
Project: live-py-plugin Source File: mock_turtle_test.py
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)
0
Example 10
Project: live-py-plugin Source File: mock_turtle_test.py
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)
0
Example 11
Project: live-py-plugin Source File: mock_turtle_test.py
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)
0
Example 12
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)
0
Example 13
Project: live-py-plugin Source File: mock_turtle_test.py
def test_get_default_color(self):
t = MockTurtle()
color = t.color()
self.assertEqual(('black', 'black'), color)
0
Example 14
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)
0
Example 15
Project: live-py-plugin Source File: mock_turtle_test.py
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)
0
Example 16
def test_stamp(self):
# SETUP
expected_report = """\
create_polygon
0
0
-9
-5
-7
0
-9
5
0
0
fill='#000000'
outline=''
create_line
0
0
-9
-5
fill='#000000'
pensize=1
create_line
-9
-5
-7
0
fill='#000000'
pensize=1
create_line
-7
0
-9
5
fill='#000000'
pensize=1
create_line
-9
5
0
0
fill='#000000'
pensize=1
"""
# EXEC
t = MockTurtle()
t.stamp()
report = t.report
# VERIFY
self.assertEqual(expected_report.splitlines(), report)
0
Example 17
Project: live-py-plugin Source File: mock_turtle_test.py
def test_forgotten_end_fill_with_stamp(self):
# SETUP
expected_report = """\
create_line
0
0
100
0
fill='#ff0000'
pensize=1
create_line
100
0
100
100
fill='#ff0000'
pensize=1
create_polygon
0
0
-9
-5
-7
0
-9
5
0
0
fill='#000000'
outline=''
create_line
0
0
-9
-5
fill='#000000'
pensize=1
create_line
-9
-5
-7
0
fill='#000000'
pensize=1
create_line
-7
0
-9
5
fill='#000000'
pensize=1
create_line
-9
5
0
0
fill='#000000'
pensize=1
"""
# EXEC
t = MockTurtle()
t.stamp()
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)