Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 19 for value_error (0.08 seconds)

  1. tests/test_filter_pydantic_sub_model_pv2.py

            client.get("/model/modelX")
        assert err.value.errors() == [
            {
                "type": "value_error",
                "loc": ("response", "name"),
                "msg": "Value error, name must end in A",
                "input": "modelX",
                "ctx": {"error": HasRepr("ValueError('name must end in A')")},
            }
        ]
    
    
    def test_openapi_schema(client: TestClient):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 6.7K bytes
    - Click Count (0)
  2. tests/test_dependency_after_yield_streaming.py

        assert response.status_code == 500
        assert response.text == "Internal Server Error"
    
    
    def test_broken_session_stream_raise():
        # Can raise ValueError on Pydantic v2 and ExceptionGroup on Pydantic v1
        with pytest.raises((ValueError, Exception)):
            client.get("/broken-session-stream")
    
    
    def test_broken_session_stream_no_raise():
        """
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 3.2K bytes
    - Click Count (0)
  3. scripts/doc_parsing_utils.py

        Syntax of comments depends on the language of the code block.
        Raises ValueError if the blocks are not compatible (different languages or different number of lines).
        """
    
        start_line = block_a["start_line_no"]
        end_line_no = start_line + len(block_a["content"]) - 1
    
        if block_a["lang"] != block_b["lang"]:
            raise ValueError(
                f"Code block (lines {start_line}-{end_line_no}) "
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:37:41 GMT 2026
    - 23.5K bytes
    - Click Count (0)
  4. 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"):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 685 bytes
    - Click Count (0)
  5. tests/test_dependency_after_yield_raise.py

        try:
            yield "s"
        except CustomError as err:
            raise HTTPException(status_code=418, detail="Session error") from err
    
    
    def broken_dep() -> Any:
        yield "s"
        raise ValueError("Broken after yield")
    
    
    app = FastAPI()
    
    
    @app.get("/catching")
    def catching(d: Annotated[str, Depends(catching_dep)]) -> Any:
        raise CustomError("Simulated error during streaming")
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 1.7K bytes
    - Click Count (0)
  6. tests/test_exception_handlers.py

            RequestValidationError: request_validation_exception_handler,
            Exception: server_error_exception_handler,
        }
    )
    
    client = TestClient(app)
    
    
    def raise_value_error():
        raise ValueError()
    
    
    def dependency_with_yield():
        yield raise_value_error()
    
    
    @app.get("/dependency-with-yield", dependencies=[Depends(dependency_with_yield)])
    def with_yield(): ...
    
    
    @app.get("/http-exception")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Dec 03 22:37:12 GMT 2024
    - 2.4K bytes
    - Click Count (0)
  7. 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
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 2K bytes
    - Click Count (0)
  8. tests/test_sse.py

    def test_server_sent_event_null_id_rejected():
        with pytest.raises(ValueError, match="null"):
            ServerSentEvent(data="test", id="has\0null")
    
    
    def test_server_sent_event_negative_retry_rejected():
        with pytest.raises(ValueError):
            ServerSentEvent(data="test", retry=-1)
    
    
    def test_server_sent_event_float_retry_rejected():
        with pytest.raises(ValueError):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 09:21:52 GMT 2026
    - 9.8K bytes
    - Click Count (0)
  9. fastapi/sse.py

        """
    
        media_type = "text/event-stream"
    
    
    def _check_id_no_null(v: str | None) -> str | None:
        if v is not None and "\0" in v:
            raise ValueError("SSE 'id' must not contain null characters")
        return v
    
    
    class ServerSentEvent(BaseModel):
        """Represents a single Server-Sent Event.
    
        When `yield`ed from a *path operation function* that uses
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 09:21:52 GMT 2026
    - 6.2K bytes
    - Click Count (0)
  10. 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:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 01 22:02:35 GMT 2025
    - 768 bytes
    - Click Count (0)
Back to Top