Files
deb-python-sqlalchemy-utils/tests/test_color.py
Ryan Leckey feb919a7b0 Change mark from xfail to skipif.
Makes tests a bit faster if requirements are not present as the whole class is skipped (rather than running each test, etc.).
2013-07-26 00:02:55 -07:00

40 lines
1.1 KiB
Python

from pytest import mark
import sqlalchemy as sa
from sqlalchemy_utils import ColorType
from sqlalchemy_utils.types import color
from tests import TestCase
@mark.skipif('color.colour is None')
class TestColorType(TestCase):
def create_models(self):
class Document(self.Base):
__tablename__ = 'document'
id = sa.Column(sa.Integer, primary_key=True)
bg_color = sa.Column(ColorType)
def __repr__(self):
return 'Document(%r)' % self.id
self.Document = Document
def test_color_parameter_processing(self):
from colour import Color
document = self.Document(
bg_color=Color(u'white')
)
self.session.add(document)
self.session.commit()
document = self.session.query(self.Document).first()
assert document.bg_color.hex == Color(u'white').hex
def test_scalar_attributes_get_coerced_to_objects(self):
from colour import Color
document = self.Document(bg_color='white')
assert isinstance(document.bg_color, Color)