Ejemplo n.º 1
0
 def test_MarkerType(self) -> None:
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo")
     assert matches(
         str(e.value),
         r"invalid value: 'foo'; allowed values are asterisk, .* or x")
Ejemplo n.º 2
0
 def test_MarkerType(self, detail):
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo", detail)
     assert str(e).endswith("ValueError") == (not detail)
Ejemplo n.º 3
0
 def test_MarkerType(self):
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo")
     assert not str(e).endswith("ValueError")
Ejemplo n.º 4
0
 def test_MarkerType(self, detail) -> None:
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo", detail)
     assert (str(e.value) == "") == (not detail)
Ejemplo n.º 5
0
                    v = rgb2hex(v)
            new_properties[k] = v
        else:
            new_properties[k] = v
    new_properties.pop('cmap', None)
    return new_properties


# Validation

alpha = Percent()
angle = Angle()
color = Color()
dash_pattern = DashPattern()
font_size = FontSize()
marker = MarkerType()
size = Size()

validators = {
    'angle':
    angle.is_valid,
    'alpha':
    alpha.is_valid,
    'color':
    lambda x: (color.is_valid(x) or
               (isinstance(x, basestring) and RGB_HEX_REGEX.match(x))),
    'font_size':
    font_size.is_valid,
    'line_dash':
    dash_pattern.is_valid,
    'marker':
Ejemplo n.º 6
0
 def test_MarkerType(self, detail):
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo", detail)
     assert str(e).endswith("ValueError") == (not detail)
Ejemplo n.º 7
0
 def test_MarkerType(self):
     p = MarkerType()
     with pytest.raises(ValueError) as e:
         p.validate("foo")
     assert not str(e).endswith("ValueError")
Ejemplo n.º 8
0
                with abbreviated_exception():
                    v = rgb2hex(v)
            new_properties[k] = v
        else:
            new_properties[k] = v
    new_properties.pop('cmap', None)
    return new_properties

# Validation

alpha     = Percent()
angle     = Angle()
color     = Color()
dash_pattern = DashPattern()
font_size = FontSize()
marker    = MarkerType()
size      = Size()

validators = {
    'angle'     : angle.is_valid,
    'alpha'     : alpha.is_valid,
    'color'     : lambda x: (
        color.is_valid(x) or (isinstance(x, basestring) and RGB_HEX_REGEX.match(x))
    ),
    'font_size' : font_size.is_valid,
    'line_dash' : dash_pattern.is_valid,
    'marker'    : lambda x: marker.is_valid(x) or x in markers,
    'size'      : size.is_valid,
}

def get_validator(style):