/
test_x256.py
34 lines (26 loc) · 893 Bytes
/
test_x256.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from twisted.trial import unittest
import x256
class Testx256(unittest.TestCase):
"""
Test class for x256 module.
"""
def setUp(self):
self.rgb = [220, 40, 150]
self.xcolor = 162
self.hex = 'DC2896'
self.aprox_hex = 'D7087'
self.aprox_rgb = [215, 0, 135]
def test_from_rgb(self):
color = x256.from_rgb(self.rgb)
self.assertEqual(self.xcolor, color)
color = x256.from_rgb(self.rgb[0], self.rgb[1], self.rgb[2])
self.assertEqual(self.xcolor, color)
def test_from_rgb(self):
color = x256.from_hex(self.hex)
self.assertEqual(self.xcolor, color)
def test_to_rgb(self):
color = x256.to_rgb(self.xcolor)
self.assertEqual(self.aprox_rgb, color)
def test_to_hex(self):
color = x256.to_hex(self.xcolor)
self.assertEqual(self.aprox_hex, color)