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_dot(patched_turtle): t2 = MockTurtle() t2.up() t2.goto(0, -2.5) t2.begin_fill() t2.circle(2.5) t2.end_fill() expected_report = t2.report MockTurtle._screen = None t = MockTurtle() t.dot() report = t.report assert report == expected_report
def test_dot(self): # SETUP t2 = MockTurtle() t2.up() t2.goto(0, -2.5) t2.begin_fill() t2.circle(2.5) t2.end_fill() expected_report = t2.report MockTurtle._screen = None # EXEC t = MockTurtle() t.dot() report = t.report # VERIFY self.assertEqual(expected_report, report)