Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 20 for value_error (0.05 sec)

  1. tests/test_openapi_schema_type.py

        schema = Schema(type=type_value)
        assert schema.type == type_value
    
    
    def test_invalid_type_value() -> None:
        """Test that Schema raises ValueError for invalid type values."""
        with pytest.raises(ValueError, match="2 validation errors for Schema"):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 730 bytes
    - Viewed (0)
  2. tests/test_dependency_after_yield_websockets.py

            self.open = True
    
        def __iter__(self) -> Generator[str, None, None]:
            for item in self.data:
                if self.open:
                    yield item
                else:
                    raise ValueError("Session closed")
    
    
    @contextmanager
    def acquire_session() -> Generator[Session, None, None]:
        session = Session()
        try:
            yield session
        finally:
            session.open = False
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 2K bytes
    - Viewed (0)
  3. docs_src/query_params_str_validations/tutorial015_an_py310.py

        "isbn-9781439512982": "Isaac Asimov: The Complete Stories, Vol. 2",
    }
    
    
    def check_valid_id(id: str):
        if not id.startswith(("isbn-", "imdb-")):
            raise ValueError('Invalid ID format, it must start with "isbn-" or "imdb-"')
        return id
    
    
    @app.get("/items/")
    async def read_items(
        id: Annotated[str | None, AfterValidator(check_valid_id)] = None,
    ):
        if id:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 01 22:02:35 UTC 2025
    - 768 bytes
    - Viewed (0)
  4. docs_src/query_params_str_validations/tutorial015_an_py39.py

        "isbn-9781439512982": "Isaac Asimov: The Complete Stories, Vol. 2",
    }
    
    
    def check_valid_id(id: str):
        if not id.startswith(("isbn-", "imdb-")):
            raise ValueError('Invalid ID format, it must start with "isbn-" or "imdb-"')
        return id
    
    
    @app.get("/items/")
    async def read_items(
        id: Annotated[Union[str, None], AfterValidator(check_valid_id)] = None,
    ):
        if id:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 01 22:02:35 UTC 2025
    - 781 bytes
    - Viewed (0)
  5. tests/test_datastructures.py

    import pytest
    from fastapi import FastAPI, UploadFile
    from fastapi.datastructures import Default
    from fastapi.testclient import TestClient
    
    
    def test_upload_file_invalid_pydantic_v2():
        with pytest.raises(ValueError):
            UploadFile._validate("not a Starlette UploadFile", {})
    
    
    def test_default_placeholder_equals():
        placeholder_1 = Default("a")
        placeholder_2 = Default("a")
        assert placeholder_1 == placeholder_2
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1.8K bytes
    - Viewed (0)
  6. tests/test_jsonable_encoder.py

        assert jsonable_encoder(item, exclude={}) == {"name": "foo", "count": 100}
    
    
    def test_encode_unsupported():
        unserializable = Unserializable()
        with pytest.raises(ValueError):
            jsonable_encoder(unserializable)
    
    
    def test_encode_custom_json_encoders_model_pydanticv2():
        from pydantic import field_serializer
    
        class ModelWithCustomEncoder(BaseModel):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 9.2K bytes
    - Viewed (0)
  7. fastapi/datastructures.py

            return await super().close()
    
        @classmethod
        def _validate(cls, __input_value: Any, _: Any) -> "UploadFile":
            if not isinstance(__input_value, StarletteUploadFile):
                raise ValueError(f"Expected UploadFile, received: {type(__input_value)}")
            return cast(UploadFile, __input_value)
    
        @classmethod
        def __get_pydantic_json_schema__(
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 5.1K bytes
    - Viewed (0)
  8. fastapi/security/http.py

                    raise self.make_not_authenticated_error()
                else:
                    return None
            try:
                data = b64decode(param).decode("ascii")
            except (ValueError, UnicodeDecodeError, binascii.Error) as e:
                raise self.make_not_authenticated_error() from e
            username, separator, password = data.partition(":")
            if not separator:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 13.2K bytes
    - Viewed (0)
  9. scripts/mkdocs_hooks.py

                elif isinstance(values[0], list):
                    resolve_files(items=values[0], files=files, config=config)
                else:
                    raise ValueError(f"Unexpected value: {values}")
    
    
    def on_files(files: Files, *, config: MkDocsConfig) -> Files:
        resolve_files(items=config.nav or [], files=files, config=config)
        if "logo" in config.theme:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 5.6K bytes
    - Viewed (0)
  10. fastapi/encoders.py

        except Exception as e:
            errors: list[Exception] = []
            errors.append(e)
            try:
                data = vars(obj)
            except Exception as e:
                errors.append(e)
                raise ValueError(errors) from e
        return jsonable_encoder(
            data,
            include=include,
            exclude=exclude,
            by_alias=by_alias,
            exclude_unset=exclude_unset,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 10.7K bytes
    - Viewed (0)
Back to top