diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-28 11:56:30 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-28 11:56:30 +1000 |
| commit | ef9f8f28c9d8e2cc10e1b56063e41d41db90efbf (patch) | |
| tree | bd353a00013721b101ff4850553ecc21859cbef0 /tests | |
| parent | 017547ff0a1dad869133c81d184a4a94f76b8f87 (diff) | |
colors: Darken bg if contrast is too low.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_util.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/test_util.py b/tests/test_util.py index b1fa704..5f8e26d 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -64,23 +64,33 @@ class TestUtil(unittest.TestCase): def test_hex_to_rgb_black(self): """> Convert #000000 to RGB.""" result = util.hex_to_rgb("#000000") - self.assertEqual(result, "0,0,0") + self.assertEqual(result, (0, 0, 0)) def test_hex_to_rgb_white(self): - """> Convert #FFFFFF to RGB.""" - result = util.hex_to_rgb("#FFFFFF") - self.assertEqual(result, "255,255,255") + """> Convert #ffffff to RGB.""" + result = util.hex_to_rgb("#ffffff") + self.assertEqual(result, (255, 255, 255)) def test_hex_to_rgb_rand(self): - """> Convert #98AEC2 to RGB.""" - result = util.hex_to_rgb("#98AEC2") - self.assertEqual(result, "152,174,194") + """> Convert #98aec2 to RGB.""" + result = util.hex_to_rgb("#98aec2") + self.assertEqual(result, (152, 174, 194)) def test_hex_to_xrgba(self): - """> Convert #98AEC2 to XRGBA.""" - result = util.hex_to_xrgba("#98AEC2") + """> Convert #98aec2 to XRGBA.""" + result = util.hex_to_xrgba("#98aec2") self.assertEqual(result, "98/ae/c2/ff") + def test_rgb_to_hex(self): + """> Convert 152,174,194 to HEX.""" + result = util.rgb_to_hex((152, 174, 194)) + self.assertEqual(result, "#98aec2") + + def test_darken_color(self): + """> Darken #ffffff by 0.25.""" + result = util.darken_color("#ffffff", 0.25) + self.assertEqual(result, "#bfbfbf") + if __name__ == "__main__": unittest.main() |
