Beispiel #1
0
 def display_diff(self, actual: LivePainter, expected: LivePainter):
     if not self.is_displayed:
         return
     if not MockTurtle.is_patched():
         return
     t = MockTurtle()
     w = t.getscreen().window_width()
     h = t.getscreen().window_height()
     ox, oy = w / 2, h / 2
     actual_width, actual_height = actual.get_size()
     expected_width, expected_height = expected.get_size()
     diff_width, diff_height = self.diff.get_size()
     text_space = (h - actual_height - diff_height - expected_height)
     text_height = max(20, text_space // 3)
     font = ('Arial', text_height // 2, 'normal')
     t.penup()
     t.goto(-ox, oy)
     t.right(90)
     t.forward(text_height)
     t.write('Actual', font=font)
     actual.display(t.pos())
     t.forward(actual_height)
     t.forward(text_height)
     t.write('Diff ({} pixels)'.format(self.diff_count), font=font)
     self.diff.display(t.pos())
     t.forward(diff_height)
     t.forward(text_height)
     t.write('Expected', font=font)
     expected.display(t.pos())
    def test_penup(self):
        # SETUP
        expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1
create_line
    150
    0
    350
    0
    fill='#000000'
    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)
Beispiel #3
0
def test_penup(patched_turtle):
    expected_report = """\
create_line
    0
    0
    100
    0
    fill='black'
    pensize=1
create_line
    150
    0
    350
    0
    fill='#000000'
    pensize=1
"""

    t = MockTurtle()
    t.fd(100)
    t.penup()
    t.fd(50)
    t.pendown()
    t.fd(200)
    report = t.report

    assert report == expected_report.splitlines()