Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 1,426 for assert (0.04 seconds)

  1. tests/test_default_response_class_router.py

        assert response.headers["content-type"] == json_type
    
    
    def test_router_a_a_override():
        with client:
            response = client.get("/a/a/override")
        assert response.content == b"Hello A A"
        assert response.headers["content-type"] == text_type
    
    
    def test_router_a_b():
        with client:
            response = client.get("/a/b")
        assert response.content == b"Hello A B"
    Created: 2026-04-05 07:19
    - Last Modified: 2020-03-01 20:49
    - 5K bytes
    - Click Count (0)
  2. tests/benchmarks/test_general_performance.py

            json={"name": "foo", "value": 123},
        )
        assert status_code == 200
        assert body == b'{"name":"foo","value":123,"dep":42}'
    
    
    def test_sync_return_dict_without_response_model(benchmark, client: TestClient) -> None:
        status_code, body = _bench_get(benchmark, client, "/sync/dict-no-response-model")
        assert status_code == 200
        assert body == b'{"name":"foo","value":123}'
    
    
    Created: 2026-04-05 07:19
    - Last Modified: 2025-12-26 20:40
    - 11.1K bytes
    - Click Count (0)
  3. tests/test_request_params/test_form/test_optional_list.py

        response = client.post(path)
        assert response.status_code == 200, response.text
        assert response.json() == {"p": None}
    
    
    @pytest.mark.parametrize(
        "path",
        ["/optional-list-str", "/model-optional-list-str"],
    )
    def test_optional_list_str(path: str):
        client = TestClient(app)
        response = client.post(path, data={"p": ["hello", "world"]})
        assert response.status_code == 200
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-17 09:59
    - 9.9K bytes
    - Click Count (0)
  4. tests/test_response_dependency.py

        def endpoint(response: Annotated[Response, Depends(modify_response)]):
            return {"status": "ok"}
    
        client = TestClient(app)
        resp = client.get("/")
    
        assert resp.status_code == 200
        assert resp.json() == {"status": "ok"}
        assert resp.headers.get("X-Custom") == "modified"
    
    
    def test_response_with_depends_default():
        """Response type hint should work with Response = Depends(...)."""
        app = FastAPI()
    
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-05 18:23
    - 5.2K bytes
    - Click Count (0)
  5. tests/test_router_events.py

            assert state.app_shutdown is False
            assert state.router_shutdown is False
            assert state.sub_router_shutdown is False
            response = client.get("/")
            assert response.status_code == 200, response.text
            assert response.json() == {"message": "Hello World"}
        assert state.app_startup is True
        assert state.router_startup is True
        assert state.sub_router_startup is True
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-17 09:59
    - 11.7K bytes
    - Click Count (0)
  6. tests/test_security_http_basic_optional.py

        assert response.status_code == 401, response.text
        assert response.headers["WWW-Authenticate"] == "Basic"
        assert response.json() == {"detail": "Not authenticated"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == snapshot(
            {
                "openapi": "3.1.0",
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-17 09:59
    - 2.7K bytes
    - Click Count (0)
  7. tests/test_dependency_contextmanager.py

        data = response.json()
        assert data["context_b"] == "started b"
        assert data["context_a"] == "started a"
        assert data["bg"] == "not set"
        middleware_state = json.loads(response.headers["x-state"])
        assert middleware_state["context_b"] == "started b"
        assert middleware_state["context_a"] == "started a"
        assert middleware_state["bg"] == "not set"
        assert state["context_b"] == "finished b with a: started a"
    Created: 2026-04-05 07:19
    - Last Modified: 2025-12-17 21:25
    - 11.5K bytes
    - Click Count (0)
  8. tests/test_jsonable_encoder.py

    def test_encode_dict():
        pet = {"name": "Firulais", "owner": {"name": "Foo"}}
        assert jsonable_encoder(pet) == {"name": "Firulais", "owner": {"name": "Foo"}}
        assert jsonable_encoder(pet, include={"name"}) == {"name": "Firulais"}
        assert jsonable_encoder(pet, exclude={"owner"}) == {"name": "Firulais"}
        assert jsonable_encoder(pet, include={}) == {}
        assert jsonable_encoder(pet, exclude={}) == {
            "name": "Firulais",
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-17 09:59
    - 9.2K bytes
    - Click Count (0)
  9. tests/test_tutorial/test_body_nested_models/test_tutorial005.py

                "tax": 3.2,
                "tags": ["foo", "bar", "foo"],
                "image": {"url": "http://example.com/image.png", "name": "example image"},
            },
        )
        assert response.status_code == 200, response.text
        assert response.json() == {
            "item_id": 123,
            "item": {
                "name": "Foo",
                "description": "A very nice Item",
                "price": 35.4,
                "tax": 3.2,
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-12 13:19
    - 10.3K bytes
    - Click Count (0)
  10. tests/test_security_http_digest_optional.py

        response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
        assert response.status_code == 200, response.text
        assert response.json() == {"scheme": "Digest", "credentials": "foobar"}
    
    
    def test_security_http_digest_no_credentials():
        response = client.get("/users/me")
        assert response.status_code == 200, response.text
        assert response.json() == {"msg": "Create an account first"}
    
    
    Created: 2026-04-05 07:19
    - Last Modified: 2026-02-17 09:59
    - 2.3K bytes
    - Click Count (0)
Back to Top