コード例 #1
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_simple_functions(self):
        turtle.forward(50)
        turtle.left(90)

        tortuga.forward(50)
        tortuga.left(90)
        self.assert_same()
コード例 #2
0
    def test_simple_functions(self):
        turtle.forward(50)
        turtle.left(90)

        tortuga.forward(50)
        tortuga.left(90)
        self.assert_same()
コード例 #3
0
    def test_color(self):
        for c in (spanish_colors):
            tortuga.color(c)
            tortuga.forward(3)

        for c in (english_colors):
            turtle.color(c)
            turtle.forward(3)

        self.assert_same()
コード例 #4
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_bgcolor(self):
        for c in (spanish_colors):
            tortuga.color_fondo(c)
            tortuga.forward(3)

        for c in (english_colors):
            turtle.bgcolor(c)
            turtle.forward(3)

        self.assert_same()
コード例 #5
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_fillcolor(self):
        for c in (spanish_colors):
            tortuga.color_de_relleno(c)
            tortuga.forward(3)

        for c in (english_colors):
            turtle.fillcolor(c)
            turtle.forward(3)

        self.assert_same()
コード例 #6
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_pencolor(self):
        for c in (spanish_colors):
            tortuga.color_de_lapiz(c)
            tortuga.forward(3)

        for c in (english_colors):
            turtle.pencolor(c)
            turtle.forward(3)

        self.assert_same()
コード例 #7
0
    def test_same_function_names_work(self):
        # draw some things using the english commands in tortuga
        tortuga.forward(50)
        tortuga.left(90)
        tortuga.forward(50)
        tortuga.right(45)
        tortuga.backward(50)
        tortuga.left(45)
        tortuga.pensize(5)
        for c in (english_colors):
            tortuga.color(c)
            tortuga.forward(10)

        # now draw the same things using turtle
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(50)
        turtle.right(45)
        turtle.backward(50)
        turtle.left(45)
        turtle.pensize(5)
        for c in (english_colors):
            turtle.color(c)
            turtle.forward(10)

        # and make sure they both resulted in the same output
        self.assert_same()
コード例 #8
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_same_function_names_work(self):
        # draw some things using the english commands in tortuga
        tortuga.forward(50)
        tortuga.left(90)
        tortuga.forward(50)
        tortuga.right(45)
        tortuga.backward(50)
        tortuga.left(45)
        tortuga.pensize(5)
        for c in (english_colors):
            tortuga.color(c)
            tortuga.forward(10)

        # now draw the same things using turtle
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(50)
        turtle.right(45)
        turtle.backward(50)
        turtle.left(45)
        turtle.pensize(5)
        for c in (english_colors):
            turtle.color(c)
            turtle.forward(10)

        # and make sure they both resulted in the same output
        self.assert_same()
コード例 #9
0
    def test_pen(self):
        some_english_colors = ['blue', (0.5, 0.3, 0.2), 'brown', 'orange']
        some_spanish_colors = ['azul', (0.5, 0.3, 0.2), 'marron', 'naranja']
        pen_options = [
            ('shown', 'se_muestra', [True, False]),
            ('pendown', 'bajar_lapiz', [True, False]),
            ('pencolor', 'color_de_lapiz', some_english_colors,
             some_spanish_colors),
            ('fillcolor', 'color_de_relleno',
             some_english_colors, some_spanish_colors),
            ('pensize', 'tamano_lapiz', [1, 2, 3, 4, 5]),
            ('speed', 'velocidad', range(1, 11)),
            ('resizemode', 'modo_cambio_tamano', ['auto', 'user', 'noresize'],
             ['auto', 'usuario', 'sin_cambio_de_tamano']),
            ('stretchfactor', 'factor_inclinacion', [(1, 1), (1, 2), (2, 1),
                                                     (2, 2)]),
            ('outline', 'ancho_contorno', [1, 2, 3]),
            ('tilt', 'rotar', [1, 2, 3])
        ]

        for entry in pen_options:
            english_key = entry[0]
            spanish_key = entry[1]
            english_values = entry[2]
            if len(entry) > 3:
                spanish_values = entry[3]
            else:
                spanish_values = english_values

            for english_value, spanish_value in zip(english_values,
                                                    spanish_values):
                turtle.clear()
                tortuga.clear()
                tortuga.pen(**{english_key: english_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)

                tortuga.pen(**{english_key: spanish_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)

                tortuga.pen(**{spanish_key: spanish_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)
                self.assert_same()
コード例 #10
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_resizemode(self):
        english_options = ['auto', 'user', 'noresize']
        spanish_options = ['auto', 'usuario', 'sin_cambio_de_tamano']

        for english_option, spanish_option in zip(english_options, spanish_options):
            tortuga.resizemode(spanish_option)
            tortuga.forward(3)
            tortuga.modo_cambio_tamano(spanish_option)
            tortuga.forward(3)
            tortuga.resizemode(english_option)
            tortuga.forward(3)

            turtle.resizemode(english_option)
            turtle.forward(3)
            turtle.resizemode(english_option)
            turtle.forward(3)
            turtle.resizemode(english_option)
            turtle.forward(3)
コード例 #11
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_shape(self):
        english_shapes = ['arrow', 'turtle', 'circle', 'square', 'triangle', 'classic']
        spanish_shapes = ['flecha', 'tortuga', 'circulo', 'cuadrado', 'triangulo', 'clasico']

        for english_shape, spanish_shape in zip(english_shapes, spanish_shapes):
            tortuga.shape(spanish_shape)
            tortuga.forward(3)
            tortuga.figura(spanish_shape)
            tortuga.forward(3)
            tortuga.shape(english_shape)
            tortuga.forward(3)

            turtle.shape(english_shape)
            turtle.forward(3)
            turtle.shape(english_shape)
            turtle.forward(3)
            turtle.shape(english_shape)
            turtle.forward(3)
コード例 #12
0
    def test_resizemode(self):
        english_options = ['auto', 'user', 'noresize']
        spanish_options = ['auto', 'usuario', 'sin_cambio_de_tamano']

        for english_option, spanish_option in zip(english_options,
                                                  spanish_options):
            tortuga.resizemode(spanish_option)
            tortuga.forward(3)
            tortuga.modo_cambio_tamano(spanish_option)
            tortuga.forward(3)
            tortuga.resizemode(english_option)
            tortuga.forward(3)

            turtle.resizemode(english_option)
            turtle.forward(3)
            turtle.resizemode(english_option)
            turtle.forward(3)
            turtle.resizemode(english_option)
            turtle.forward(3)
コード例 #13
0
ファイル: turtleTest.py プロジェクト: asweigart/tortuga
    def test_pen(self):
        some_english_colors = ['blue', (0.5, 0.3, 0.2), 'brown', 'orange']
        some_spanish_colors = ['azul', (0.5, 0.3, 0.2), 'marron', 'naranja']
        pen_options = [('shown', 'se_muestra', [True, False]),
                       ('pendown', 'bajar_lapiz', [True, False]),
                       ('pencolor', 'color_de_lapiz', some_english_colors, some_spanish_colors),
                       ('fillcolor', 'color_de_relleno', some_english_colors, some_spanish_colors),
                       ('pensize', 'tamano_lapiz', [1, 2, 3, 4, 5]),
                       ('speed', 'velocidad', range(1, 11)),
                       ('resizemode', 'modo_cambio_tamano', ['auto', 'user', 'noresize'], ['auto', 'usuario', 'sin_cambio_de_tamano']),
                       ('stretchfactor', 'factor_inclinacion', [(1, 1), (1, 2), (2, 1), (2, 2)]),
                       ('outline', 'ancho_contorno', [1, 2, 3]),
                       ('tilt', 'rotar', [1, 2, 3])]

        for entry in pen_options:
            english_key = entry[0]
            spanish_key = entry[1]
            english_values = entry[2]
            if len(entry) > 3:
                spanish_values = entry[3]
            else:
                spanish_values = english_values

            for english_value, spanish_value in zip(english_values, spanish_values):
                self.clear()
                tortuga.pen(**{english_key: english_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)

                tortuga.pen(**{english_key: spanish_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)

                tortuga.pen(**{spanish_key: spanish_value})
                tortuga.forward(3)

                turtle.pen(**{english_key: english_value})
                turtle.forward(3)
                self.assert_same()
コード例 #14
0
    def test_shape(self):
        english_shapes = [
            'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'
        ]
        spanish_shapes = [
            'flecha', 'tortuga', 'circulo', 'cuadrado', 'triangulo', 'clasico'
        ]

        for english_shape, spanish_shape in zip(english_shapes,
                                                spanish_shapes):
            tortuga.shape(spanish_shape)
            tortuga.forward(3)
            tortuga.figura(spanish_shape)
            tortuga.forward(3)
            tortuga.shape(english_shape)
            tortuga.forward(3)

            turtle.shape(english_shape)
            turtle.forward(3)
            turtle.shape(english_shape)
            turtle.forward(3)
            turtle.shape(english_shape)
            turtle.forward(3)
コード例 #15
0
ファイル: guiTest.py プロジェクト: cccczl/tortuga
# This is not a unit test. Instead, it is a general test to make sure the Spanish-named function calls produce an identical drawing.
# This needs to be automated and have more coverage.

import sys
import os

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import tortuga

tortuga.forward(50)
tortuga.left(90)
tortuga.forward(50)
tortuga.right(45)
tortuga.backward(50)
tortuga.left(45)
tortuga.pensize(5)
for c in ('blue brown orange gray green purple pink yellow white black red'.split()):
    tortuga.color(c)
    tortuga.forward(10)

t = tortuga.Tortuga()
t.subir_lapiz()
t.ir_a(-100, 0)
t.bajar_lapiz()
t.adelante(50)
t.izquierda(90)
t.adelante(50)
t.derecho(45)
t.atras(50)
t.izquierda(45)
t.tamano_lapiz(5)