Exemplo n.º 1
0
def test_forgotten_end_fill(patched_turtle):
    expected_report = """\
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)
    report = t.report

    assert report == expected_report.splitlines()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
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
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
def test_forgotten_end_fill_with_stamp(patched_turtle):
    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
create_line
    0
    0
    100
    0
    fill='#ff0000'
    pensize=1
create_line
    100
    0
    100
    100
    fill='#ff0000'
    pensize=1
"""

    t = MockTurtle()
    t.stamp()
    t.color('red', 'blue')
    t.begin_fill()
    for _ in range(2):
        t.fd(100)
        t.right(90)
    report = t.report

    assert report == expected_report.splitlines()
Exemplo n.º 8
0
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()