Beispiel #1
0
    def test_shape_at_angle_0_has_source_coords(self):

        coords = [0, 0, 2, 0, 1, 1]
        shape = vector.Shape(coords)

        result = shape[0]
        self.assert_almost_equal_coords(result, coords, places=1)
    def test_create_sprite_from_vector_shape(self):

        canvas = object()
        shape = vector.Shape([1, 2, 3, 4])

        sprite = sprites.create_sprite(
            canvas,
            shape,
            anchor=(42, 24),
            angle=180,
        )

        # One sprite was created with the expected arguments.
        self.vector_sprite_mock.assert_called_once_with(
            canvas,
            shape,
            anchor=(42, 24),
            angle=180,
            speed=360,
            m_speed=None,
            r_speed=None,
            easing=None,
            m_easing=None,
            r_easing=None,
            m_callback=None,
            r_callback=None,
            fps=80,
            update=False,
        )

        # Result is what calling the Sprite class produced.
        self.assertIs(sprite, self.vector_sprite_mock.return_value)
Beispiel #3
0
    def test_create_with_bad_typed_coords_raises_TypeError(self):

        bad_values = (None, 42, 'hi', (i for i in range(10)))

        for bad_value in bad_values:
            with self.subTest(bad_value=bad_value):
                with self.assertRaises(TypeError):
                    _shape = vector.Shape(coords=bad_value)
Beispiel #4
0
    def test_shape_coords_at_angle_270(self):

        shape = vector.Shape([0, 0, 2, 0, 1, 1])

        result = shape[270]
        self.assert_almost_equal_coords(result, [0, 0, 0, -2, 1, -1], places=1)
Beispiel #5
0
    def test_shape_line_width_is_tracked(self):

        line_width = 42
        shape = vector.Shape([0, 0, 2, 0, 1, 1], line_width=line_width)

        self.assertEqual(shape.line_width, line_width)
Beispiel #6
0
    def test_shape_line_color_is_tracked(self):

        line_color = 'navy blue'
        shape = vector.Shape([0, 0, 2, 0, 1, 1], line_color=line_color)

        self.assertEqual(shape.line_color, line_color)
Beispiel #7
0
    def test_shape_fill_color_is_tracked(self):

        fill_color = 'nice hot pink'
        shape = vector.Shape([0, 0, 2, 0, 1, 1], fill_color=fill_color)

        self.assertEqual(shape.fill_color, fill_color)
Beispiel #8
0
    def test_shape_anchor_is_tracked(self):

        anchor = (42, 24)
        shape = vector.Shape([0, 0, 2, 0, 1, 1], anchor=anchor)

        self.assertEqual(shape.anchor, anchor)
Beispiel #9
0
    def test_create_with_odd_number_of_coords_raises_ValueError(self):

        with self.assertRaises(ValueError):
            _shape = vector.Shape([1, 2, 3])