Skip to content

Commit

Permalink
Added tests with trial and .travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
magarcia committed May 12, 2012
1 parent 6f39d4e commit 5c26b44
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -28,3 +28,6 @@ pip-log.txt

#Mac OSX
.DS_Store

#Trial
_trial_temp
7 changes: 7 additions & 0 deletions .travis.yml
@@ -0,0 +1,7 @@
language: python
python:
- 2.6
- 2.7

install: python setup.py install
script: trial klein
34 changes: 34 additions & 0 deletions 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)

0 comments on commit 5c26b44

Please sign in to comment.