Exemplo n.º 1
0
 def test_validate_str(
     self, provided: Any, optional: bool, required: bool, expected: Optional[str]
 ) -> None:
     """Test _validate_str."""
     assert (
         BaseModel._validate_str(provided, optional=optional, required=required)
         == expected
     )
Exemplo n.º 2
0
 def test_validate_str_value_error(self) -> None:
     """Test _validate_str raise ValueError."""
     with pytest.raises(ValueError):
         BaseModel._validate_str(None, required=True)
     with pytest.raises(ValueError):
         BaseModel._validate_str("", required=True)
Exemplo n.º 3
0
 def test_validate_str_type_error(self, provided: Any) -> None:
     """Test _validate_str raise TypeError."""
     with pytest.raises(TypeError):
         BaseModel._validate_str(provided)