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 )
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)
def test_validate_str_type_error(self, provided: Any) -> None: """Test _validate_str raise TypeError.""" with pytest.raises(TypeError): BaseModel._validate_str(provided)