def test_is_filling(): t = MockTurtle() is_filling1 = t.fill() t.begin_fill() is_filling2 = t.fill() t.end_fill() is_filling3 = t.fill() assert not is_filling1 assert is_filling2 assert not is_filling3
def test_is_filling(self): # SETUP # EXEC t = MockTurtle() is_filling1 = t.fill() t.begin_fill() is_filling2 = t.fill() t.end_fill() is_filling3 = t.fill() # VERIFY self.assertFalse(is_filling1) self.assertTrue(is_filling2) self.assertFalse(is_filling3)
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)
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)
def test_fill(patched_turtle): 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""" 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 assert report == expected_report.splitlines()
def test_stamp_while_filling(patched_turtle): expected_report = """\ create_polygon 0 0 40 0 40 40 0 40 fill='#008000' outline='' create_line 0 0 40 0 fill='black' pensize=4 create_line 40 0 40 40 fill='black' pensize=4 create_line 40 40 0 40 fill='black' pensize=4 create_polygon 40 0 45 -9 40 -7 35 -9 fill='#008000' outline='' create_line 40 0 45 -9 fill='black' pensize=1 create_line 45 -9 40 -7 fill='black' pensize=1 create_line 40 -7 35 -9 fill='black' pensize=1 create_line 35 -9 40 0 fill='black' pensize=1 """ t = MockTurtle() t.pensize(4) t.fillcolor('green') t.begin_fill() t.forward(40) t.right(90) t.stamp() t.forward(40) t.right(90) t.forward(40) t.end_fill() report = t.report assert report == expected_report.splitlines()