def test_DashPattern(self) -> None: p = DashPattern() with pytest.raises(ValueError) as e: p.validate("junk") assert matches( str(e.value), r"expected an element of either Enum\(.*\), Regex\(.*\) or Seq\(Int\), got 'junk'" )
def test_Property_wrap() -> None: types = [ Bool(), Int(), Float(), Complex(), String(), Enum("Some", "a", "b"), Color(), Regex("^$"), Seq(Any), Tuple(Any, Any), Instance(_TestModel), Any(), Interval(Float, 0, 1), Either(Int, String), DashPattern(), Size(), Percent(), Angle(), MinMaxBounds(), ] for x in types: for y in (0, 1, 2.3, "foo", None, (), [], {}): r = x.wrap(y) assert r == y assert isinstance(r, type(y))
def test_DashPattern(self, detail): p = DashPattern() with pytest.raises(ValueError) as e: p.validate("junk", detail) assert str(e).endswith("ValueError") == (not detail)
def test_DashPattern(self): p = DashPattern() with pytest.raises(ValueError) as e: p.validate("junk") assert not str(e).endswith("ValueError")
def test_DashPattern(self, detail) -> None: p = DashPattern() with pytest.raises(ValueError) as e: p.validate("junk", detail) assert (str(e.value) == "") == (not detail)
if isinstance(v, tuple): 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':