From 5c26b442b3c2363de333b7adf702e35924b33662 Mon Sep 17 00:00:00 2001 From: Martin Garcia Date: Sat, 12 May 2012 17:49:34 -0500 Subject: [PATCH] Added tests with trial and .travis.yml --- .gitignore | 3 +++ .travis.yml | 7 +++++++ x256/test_x256.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .travis.yml create mode 100644 x256/test_x256.py diff --git a/.gitignore b/.gitignore index 4b3e586..74007a4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ pip-log.txt #Mac OSX .DS_Store + +#Trial +_trial_temp diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..769ab81 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - 2.6 + - 2.7 + +install: python setup.py install +script: trial klein diff --git a/x256/test_x256.py b/x256/test_x256.py new file mode 100644 index 0000000..634bd8c --- /dev/null +++ b/x256/test_x256.py @@ -0,0 +1,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) \ No newline at end of file