def test_MinMaxBounds(self) -> None: p = MinMaxBounds() with pytest.raises(ValueError) as e: p.validate(10) assert matches( str(e.value), r"expected an element of either Auto, Tuple\(Float, Float\) or Tuple\(TimeDelta, TimeDelta\), got 10" )
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_MinMaxBounds(self, detail): p = MinMaxBounds() with pytest.raises(ValueError) as e: p.validate(10, detail) assert str(e).endswith("ValueError") == (not detail)
def test_MinMaxBounds(self): p = MinMaxBounds() with pytest.raises(ValueError) as e: p.validate(10) assert not str(e).endswith("ValueError")
def test_MinMaxBounds(self, detail) -> None: p = MinMaxBounds() with pytest.raises(ValueError) as e: p.validate(10, detail) assert (str(e.value) == "") == (not detail)
def test_MinMaxBounds(self) -> None: p = MinMaxBounds() with pytest.raises(ValueError) as e: p.validate(10) assert matches(str(e.value), r"expected an element of either .*, got 10")