Skip to content

Commit db8137a

Browse files
committed
Update tests
1 parent d29016b commit db8137a

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

colosseum/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def value(self, context):
350350
BACKGROUND_COLOR_CHOICES = Choices(default, TRANSPARENT, validators=[is_color])
351351

352352
# background_image
353-
BACKGROUND_IMAGE_CHOICES = Choices(validators=[is_uri], explicit_defaulting_constants=[INHERIT])
353+
BACKGROUND_IMAGE_CHOICES = Choices(None, validators=[is_uri], explicit_defaulting_constants=[INHERIT, INITIAL])
354354

355355
# background_repeat
356356
REPEAT = 'repeat'
@@ -364,10 +364,10 @@ def value(self, context):
364364
SCROLL = 'scroll'
365365
FIXED = 'fixed'
366366

367-
BACKGROUND_ATTACHMENT_CHOICES = Choices(SCROLL, FIXED, explicit_defaulting_constants=[INHERIT])
367+
BACKGROUND_ATTACHMENT_CHOICES = Choices(SCROLL, FIXED, explicit_defaulting_constants=[INHERIT, INITIAL])
368368

369369
# background_position
370-
BACKGROUND_POSITION_CHOICES = Choices(validators=is_position, explicit_defaulting_constants=[INHERIT])
370+
BACKGROUND_POSITION_CHOICES = Choices(validators=[is_position], explicit_defaulting_constants=[INHERIT])
371371

372372
# background
373373

colosseum/declaration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
)
2727
from .exceptions import ValidationError
2828
from .wrappers import (
29-
Border, BorderBottom, BorderLeft, BorderRight, BorderTop, Outline,
29+
Background, Border, BorderBottom, BorderLeft, BorderRight, BorderTop,
30+
Outline,
3031
)
3132

3233
_CSS_PROPERTIES = set()
@@ -115,7 +116,6 @@ def validated_property(name, choices, initial):
115116
# Check the value attribute is a callable
116117
if not callable(value_attr):
117118
raise ValueError('Initial value "%s" `value` attribute is not callable!' % initial)
118-
119119
except AttributeError:
120120
raise ValueError('Initial value "%s" does not have a value attribute!' % initial)
121121

colosseum/parser.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def outline(value):
286286

287287

288288
##############################################################################
289-
# # Border shorthands
289+
# Border shorthands
290290
##############################################################################
291291
def _parse_border_property_part(value, border_dict, direction=None):
292292
"""Parse border shorthand property part for known properties."""
@@ -472,7 +472,7 @@ def position(value):
472472
# <length> values are allowed.
473473
try:
474474
return Position(horizontal=units(values[0]))
475-
except ValueError as error:
475+
except ValueError:
476476
if values[0] in ['left', 'right', 'center']:
477477
return Position(horizontal=values[0])
478478

@@ -485,7 +485,7 @@ def position(value):
485485
# Check first value
486486
try:
487487
horizontal = units(values[0])
488-
except ValueError as error:
488+
except ValueError:
489489
if values[0] in ['left', 'center', 'right']:
490490
horizontal = values[0]
491491

@@ -495,7 +495,7 @@ def position(value):
495495
# Check second value
496496
try:
497497
vertical = units(values[1])
498-
except ValueError as error:
498+
except ValueError:
499499
if values[1] in ['left', 'center', 'right']:
500500
horizontal = values[1]
501501

@@ -510,7 +510,7 @@ def position(value):
510510
##############################################################################
511511
# Background shorthand
512512
##############################################################################
513-
def _parse_background_property_part(value, outline_dict):
513+
def _parse_background_property_part(value, background_dict):
514514
"""Parse background shorthand property part for known properties."""
515515
from .constants import ( # noqa
516516
BACKGROUND_ATTACHMENT_CHOICES, BACKGROUND_COLOR_CHOICES, BACKGROUND_IMAGE_CHOICES,
@@ -527,11 +527,11 @@ def _parse_background_property_part(value, outline_dict):
527527
except (ValueError, ValidationError):
528528
continue
529529

530-
if property_name in border_dict:
530+
if property_name in background_dict:
531531
raise ValueError('Invalid duplicated property!')
532532

533-
border_dict[property_name] = value
534-
return border_dict
533+
background_dict[property_name] = value
534+
return background_dict
535535

536536
raise ValueError('Background value "{value}" not valid!'.format(value=value))
537537

colosseum/validators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def is_cursor(value):
183183
except ValueError as error:
184184
raise ValidationError(str(error))
185185

186+
return value
187+
186188

187189
is_cursor.description = ('[ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize '
188190
'| ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize '

colosseum/wrappers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ class Border(Shorthand):
198198
VALID_KEYS = ['border_width', 'border_style', 'border_color']
199199

200200

201+
class Background(Shorthand):
202+
VALID_KEYS = ['background_color', 'background_image', 'background_repeat', 'background_attachment',
203+
'background_position']
204+
205+
201206
class Uri:
202207
"""Wrapper for a url."""
203208

0 commit comments

Comments
 (0)