def test_Angle(self): p = Angle() with pytest.raises(ValueError) as e: p.validate("junk") assert matches( str(e.value), r"expected a value of type Real, got junk of type (str|unicode)")
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))
class ArcGlyph(LineGlyph): """Represents a group of data as an arc.""" start_angle = Angle() end_angle = Angle() def __init__(self, **kwargs): super(self.__class__, self).__init__(**kwargs) self.setup() def build_renderers(self): """Yield a `GlyphRenderer` for the group of data.""" glyph = Arc(x='x', y='y', radius=1, start_angle='_end_angle', end_angle='_start_angle', line_color='line_color') yield GlyphRenderer(glyph=glyph)
def test_Angle(self): p = Angle() with pytest.raises(ValueError) as e: p.validate("junk") assert not str(e).endswith("ValueError")
def test_Angle(self, detail): p = Angle() with pytest.raises(ValueError) as e: p.validate("junk", detail) assert str(e).endswith("ValueError") == (not detail)
def test_Angle(self, detail) -> None: p = Angle() with pytest.raises(ValueError) as e: p.validate("junk", detail) assert (str(e.value) == "") == (not detail)
with abbreviated_exception(): v = COLOR_ALIASES.get(v, v) 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':