Exemple #1
0
    def test_diffrent_color_place(self):
        c = Circle.parse({
            'x': 1,
            'y': 2,
            'radius': 3,
            'color': '#0000ff'
        }, {}, Color("#123456"))
        self.assertEqual(c.color, Color("#0000ff"))

        c = Circle.parse({
            'x': 1,
            'y': 2,
            'radius': 3,
            'color': 'aaa'
        }, {'aaa': "#ff0000"}, Color("#123456"))
        self.assertEqual(c.color, Color("#ff0000"))
Exemple #2
0
    def test_errors(self):
        with self.assertRaises(ValueError):
            Circle.parse({'xq': 1, 'y': 2, 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'y': 2, 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'yq': 2, 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': 2, 'radiusqq': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': 2}, {}, Color("#123456"))
        with self.assertRaises(ValueError):
            Circle.parse({'x': 1, 'y': 2, 'radius': 3}, {}, Color("#123456"))

        with self.assertRaises(TypeError):
            Circle.parse({'x': (), 'y': 2, 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': [], 'radius': 3}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': 2, 'radius': {}}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': 2, 'radius': {}}, {}, Color("#123456"))
            Circle.parse({'x': 1, 'y': 2, 'radius': 3}, {}, Color("#1"))
Exemple #3
0
 def test_parse(self):
     c = Circle.parse({'x': 1, 'y': 2, 'radius': 3}, {}, Color("#123456"))
     self.assertEqual(c.x, 1)
     self.assertEqual(c.y, 2)
     self.assertEqual(c.radius, 3)
     self.assertEqual(c.color, Color("#123456"))