Esempio n. 1
0
    def test_diffrent_color_place(self):
        p = Point.parse({
            'x': 10,
            'y': 2,
            'color': 'cos'
        }, {'cos': "#123456"}, Color("#990011"))
        self.assertEqual(p.color, Color("#123456"))

        p = Point.parse({'x': 10, 'y': 2}, {'cos': "123456"}, Color("#123456"))
        self.assertEqual(p.color, Color("#123456"))
Esempio n. 2
0
 def test_parse(self):
     p = Point.parse({
         'x': 10,
         'y': 2,
         'color': '(255, 0, 255)'
     }, {}, Color("#990011"))
     self.assertEqual(p.x, 10)
     self.assertEqual(p.y, 2)
     self.assertEqual(p.color, Color("#ff00ff"))
Esempio n. 3
0
    def test_errors(self):
        with self.assertRaises(ValueError):
            Point.parse({
                'x': 10,
                'color': '(255, 0, 255)'
            }, {}, Color("#990011"))
            Point.parse({
                'y': 2,
                'color': '(255, 0, 255)'
            }, {}, Color("#990011"))

        with self.assertRaises(TypeError):
            Point.parse({
                'x': 10,
                'y': "",
                'color': '(255, 0, 255)'
            }, {}, Color("#990011"))
            Point.parse({
                'x': {},
                'y': 2,
                'color': '(255, 0, 255)'
            }, {}, Color("#990011"))