diff --git a/setup.py b/setup.py index a321aa1..2160077 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,8 @@ extras_require = { 'psycopg2>=2.5.1', 'pytz>=2014.2', 'python-dateutil>=2.2', - 'pymysql' + 'pymysql', + 'colour>=0.0.4' ], 'anyjson': ['anyjson>=0.3.3'], 'babel': ['Babel>=1.3'], diff --git a/sqlalchemy_utils/types/color.py b/sqlalchemy_utils/types/color.py index 0064243..dbe743f 100644 --- a/sqlalchemy_utils/types/color.py +++ b/sqlalchemy_utils/types/color.py @@ -6,8 +6,9 @@ from .scalar_coercible import ScalarCoercible colour = None try: import colour + python_colour_type = colour.Color except ImportError: - pass + python_colour_type = None class ColorType(types.TypeDecorator, ScalarCoercible): @@ -49,7 +50,7 @@ class ColorType(types.TypeDecorator, ScalarCoercible): """ STORE_FORMAT = u'hex' impl = types.Unicode(20) - python_type = colour.Color + python_type = python_colour_type def __init__(self, max_length=20, *args, **kwargs): # Fail if colour is not found. diff --git a/tests/types/test_color.py b/tests/types/test_color.py index 5d970b1..5af476b 100644 --- a/tests/types/test_color.py +++ b/tests/types/test_color.py @@ -6,7 +6,7 @@ from sqlalchemy_utils.types import color from tests import TestCase -@mark.skipif('color.colour is None') +@mark.skipif('color.python_colour_type is None') class TestColorType(TestCase): def create_models(self): class Document(self.Base):