repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/celery/src/task_app/views.py | examples/celery/src/task_app/views.py | from celery.result import AsyncResult
from flask import Blueprint
from flask import request
from . import tasks
bp = Blueprint("tasks", __name__, url_prefix="/tasks")
@bp.get("/result/<id>")
def result(id: str) -> dict[str, object]:
result = AsyncResult(id)
ready = result.ready()
return {
"ready... | python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/celery/src/task_app/__init__.py | examples/celery/src/task_app/__init__.py | from celery import Celery
from celery import Task
from flask import Flask
from flask import render_template
def create_app() -> Flask:
app = Flask(__name__)
app.config.from_mapping(
CELERY=dict(
broker_url="redis://localhost",
result_backend="redis://localhost",
tas... | python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/javascript/js_example/views.py | examples/javascript/js_example/views.py | from flask import jsonify
from flask import render_template
from flask import request
from . import app
@app.route("/", defaults={"js": "fetch"})
@app.route("/<any(xhr, jquery, fetch):js>")
def index(js):
return render_template(f"{js}.html", js=js)
@app.route("/add", methods=["POST"])
def add():
a = reques... | python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/javascript/js_example/__init__.py | examples/javascript/js_example/__init__.py | from flask import Flask
app = Flask(__name__)
from js_example import views # noqa: E402, F401
| python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/javascript/tests/test_js_example.py | examples/javascript/tests/test_js_example.py | import pytest
from flask import template_rendered
@pytest.mark.parametrize(
("path", "template_name"),
(
("/", "fetch.html"),
("/plain", "xhr.html"),
("/fetch", "fetch.html"),
("/jquery", "jquery.html"),
),
)
def test_index(app, client, path, template_name):
def check(s... | python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
pallets/flask | https://github.com/pallets/flask/blob/2579ce9f18e67ec3213c6eceb5240310ccd46af8/examples/javascript/tests/conftest.py | examples/javascript/tests/conftest.py | import pytest
from js_example import app
@pytest.fixture(name="app")
def fixture_app():
app.testing = True
yield app
app.testing = False
@pytest.fixture
def client(app):
return app.test_client()
| python | BSD-3-Clause | 2579ce9f18e67ec3213c6eceb5240310ccd46af8 | 2026-01-04T14:38:18.898398Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/sites.py | sherlock_project/sites.py | """Sherlock Sites Information Module
This module supports storing information about websites.
This is the raw data that will be used to search for usernames.
"""
import json
import requests
import secrets
MANIFEST_URL = "https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock_project/resources/da... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/result.py | sherlock_project/result.py | """Sherlock Result Module
This module defines various objects for recording the results of queries.
"""
from enum import Enum
class QueryStatus(Enum):
"""Query Status Enumeration.
Describes status of query about a given username.
"""
CLAIMED = "Claimed" # Username Detected
AVAILABLE = "Avail... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/__main__.py | sherlock_project/__main__.py | #! /usr/bin/env python3
"""
Sherlock: Find Usernames Across Social Networks Module
This module contains the main logic to search for usernames at social
networks.
"""
import sys
if __name__ == "__main__":
# Check if the user is using the correct version of Python
python_version = sys.version.split()[0]
... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/sherlock.py | sherlock_project/sherlock.py | #! /usr/bin/env python3
"""
Sherlock: Find Usernames Across Social Networks Module
This module contains the main logic to search for usernames at social
networks.
"""
import sys
try:
from sherlock_project.__init__ import import_error_test_var # noqa: F401
except ImportError:
print("Did you run Sherlock with... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | true |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/__init__.py | sherlock_project/__init__.py | """ Sherlock Module
This module contains the main logic to search for usernames at social
networks.
"""
from importlib.metadata import version as pkg_version, PackageNotFoundError
import pathlib
import tomli
def get_version() -> str:
"""Fetch the version number of the installed package."""
try:
ret... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/sherlock_project/notify.py | sherlock_project/notify.py | """Sherlock Notify Module
This module defines the objects for notifying the caller about the
results of queries.
"""
from sherlock_project.result import QueryStatus
from colorama import Fore, Style
import webbrowser
# Global variable to count the number of results.
globvar = 0
class QueryNotify:
"""Query Notify... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/test_manifest.py | tests/test_manifest.py | import os
import json
import pytest
from jsonschema import validate
def test_validate_manifest_against_local_schema():
"""Ensures that the manifest matches the local schema, for situations where the schema is being changed."""
json_relative: str = '../sherlock_project/resources/data.json'
schema_relative: ... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/conftest.py | tests/conftest.py | import os
import json
import urllib
import pytest
from sherlock_project.sites import SitesInformation
def fetch_local_manifest(honor_exclusions: bool = True) -> dict[str, dict[str, str]]:
sites_obj = SitesInformation(data_file_path=os.path.join(os.path.dirname(__file__), "../sherlock_project/resources/data.json"),... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/test_validate_targets.py | tests/test_validate_targets.py | import pytest
import re
import rstr
from sherlock_project.sherlock import sherlock
from sherlock_project.notify import QueryNotify
from sherlock_project.result import QueryResult, QueryStatus
FALSE_POSITIVE_ATTEMPTS: int = 2 # Since the usernames are randomly generated, it's POSSIBLE that a real username can be h... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/sherlock_interactives.py | tests/sherlock_interactives.py | import os
import platform
import re
import subprocess
class Interactives:
def run_cli(args:str = "") -> str:
"""Pass arguments to Sherlock as a normal user on the command line"""
# Adapt for platform differences (Windows likes to be special)
if platform.system() == "Windows":
co... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/test_version.py | tests/test_version.py | import os
from sherlock_interactives import Interactives
import sherlock_project
def test_versioning() -> None:
# Ensure __version__ matches version presented to the user
assert sherlock_project.__version__ in Interactives.run_cli("--version")
# Ensure __init__ is single source of truth for __version__ in ... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/test_ux.py | tests/test_ux.py | import pytest
from sherlock_project import sherlock
from sherlock_interactives import Interactives
from sherlock_interactives import InteractivesSubprocessError
def test_remove_nsfw(sites_obj):
nsfw_target: str = 'Pornhub'
assert nsfw_target in {site.name: site.information for site in sites_obj}
sites_obj.... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/test_probes.py | tests/test_probes.py | import pytest
import random
import string
import re
from sherlock_project.sherlock import sherlock
from sherlock_project.notify import QueryNotify
from sherlock_project.result import QueryStatus
#from sherlock_interactives import Interactives
def simple_query(sites_info: dict, site: str, username: str) -> QueryStatus... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/tests/few_test_basic.py | tests/few_test_basic.py | import sherlock_project
#from sherlock.sites import SitesInformation
#local_manifest = data_file_path=os.path.join(os.path.dirname(__file__), "../sherlock/resources/data.json")
def test_username_via_message():
sherlock_project.__main__("--version")
| python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/devel/site-list.py | devel/site-list.py | #!/usr/bin/env python
# This module generates the listing of supported sites which can be found in
# sites.mdx. It also organizes all the sites in alphanumeric order
import json
import os
DATA_REL_URI: str = "sherlock_project/resources/data.json"
DEFAULT_ENCODING = "utf-8"
# Read the data.json file
with open(DATA_RE... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
sherlock-project/sherlock | https://github.com/sherlock-project/sherlock/blob/8f1308b90d2b79296ce78d666e53d9be919efe02/devel/summarize_site_validation.py | devel/summarize_site_validation.py | #!/usr/bin/env python
# This module summarizes the results of site validation tests queued by
# workflow validate_modified_targets for presentation in Issue comments.
from defusedxml import ElementTree as ET
import sys
from pathlib import Path
def summarize_junit_xml(xml_path: Path) -> str:
tree = ET.parse(xml_pa... | python | MIT | 8f1308b90d2b79296ce78d666e53d9be919efe02 | 2026-01-04T14:38:17.815883Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/pdm_build.py | pdm_build.py | import os
from typing import Any
from pdm.backend.hooks import Context
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "fastapi")
def pdm_build_initialize(context: Context) -> None:
metadata = context.config.metadata
# Get custom config for the current package, from the env var
config: dict... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/translate.py | scripts/translate.py | import json
import secrets
import subprocess
from collections.abc import Iterable
from functools import lru_cache
from os import sep as pathsep
from pathlib import Path
from typing import Annotated
import git
import typer
import yaml
from github import Github
from pydantic_ai import Agent
from rich import print
non_t... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/sponsors.py | scripts/sponsors.py | import logging
import secrets
import subprocess
from collections import defaultdict
from pathlib import Path
from typing import Any
import httpx
import yaml
from github import Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
github_graphql_url = "https://api.github.com/graph... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/label_approved.py | scripts/label_approved.py | import logging
from typing import Literal
from github import Github
from github.PullRequestReview import PullRequestReview
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
class LabelSettings(BaseModel):
await_label: str | None = None
number: int
default_config = {"appro... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/notify_translations.py | scripts/notify_translations.py | import logging
import random
import sys
import time
from pathlib import Path
from typing import Any, Union, cast
import httpx
from github import Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
awaiting_label = "awaiting-review"
lang_all_label = "lang-all"
approved_label = "... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/people.py | scripts/people.py | import logging
import secrets
import subprocess
import time
from collections import Counter
from collections.abc import Container
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any, Union
import httpx
import yaml
from github import Github
from pydantic import BaseModel, ... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/docs.py | scripts/docs.py | import json
import logging
import os
import re
import shutil
import subprocess
from html.parser import HTMLParser
from http.server import HTTPServer, SimpleHTTPRequestHandler
from multiprocessing import Pool
from pathlib import Path
from typing import Any, Optional, Union
import mkdocs.utils
import typer
import yaml
f... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/mkdocs_hooks.py | scripts/mkdocs_hooks.py | from functools import lru_cache
from pathlib import Path
from typing import Any, Union
import material
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.nav import Link, Navigation, Section
from mkdocs.structure.pages import Page
non_translated_sectio... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/deploy_docs_status.py | scripts/deploy_docs_status.py | import logging
import re
from typing import Literal
from github import Auth, Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
github_repository: str
github_token: SecretStr
deploy_url: str | None = None
commit_sha: str
run_i... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/contributors.py | scripts/contributors.py | import logging
import secrets
import subprocess
from collections import Counter
from datetime import datetime
from pathlib import Path
from typing import Any
import httpx
import yaml
from github import Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
github_graphql_url = "ht... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/topic_repos.py | scripts/topic_repos.py | import logging
import secrets
import subprocess
from pathlib import Path
import yaml
from github import Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
github_repository: str
github_token: SecretStr
class Repo(BaseModel):
name: s... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/query_param_models/image01.py | scripts/playwright/query_param_models/image01.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/cookie_param_models/image01.py | scripts/playwright/cookie_param_models/image01.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/sql_databases/image01.py | scripts/playwright/sql_databases/image01.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/sql_databases/image02.py | scripts/playwright/sql_databases/image02.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/request_form_models/image01.py | scripts/playwright/request_form_models/image01.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/header_param_models/image01.py | scripts/playwright/header_param_models/image01.py | import subprocess
import time
import httpx
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manu... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/separate_openapi_schemas/image01.py | scripts/playwright/separate_openapi_schemas/image01.py | import subprocess
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manually
context = browse... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/separate_openapi_schemas/image05.py | scripts/playwright/separate_openapi_schemas/image05.py | import subprocess
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manually
context = browse... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/separate_openapi_schemas/image02.py | scripts/playwright/separate_openapi_schemas/image02.py | import subprocess
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manually
context = browse... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/separate_openapi_schemas/image04.py | scripts/playwright/separate_openapi_schemas/image04.py | import subprocess
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manually
context = browse... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/scripts/playwright/separate_openapi_schemas/image03.py | scripts/playwright/separate_openapi_schemas/image03.py | import subprocess
from playwright.sync_api import Playwright, sync_playwright
# Run playwright codegen to generate the code below, copy paste the sections in run()
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
# Update the viewport manually
context = browse... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_annotated.py | tests/test_annotated.py | from typing import Annotated
import pytest
from fastapi import APIRouter, FastAPI, Query
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/default")
async def default(foo: Annotated[str, Query()] = "foo"):
return {"foo": foo}
@app.get("/required")
async def required(foo: Annotated[str, Quer... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_swagger_ui_init_oauth.py | tests/test_swagger_ui_init_oauth.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
swagger_ui_init_oauth = {"clientId": "the-foo-clients", "appName": "The Predendapp"}
app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth)
@app.get("/items/")
async def read_items():
return {"id": "foo"}
client = TestClient(app)
def ... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_param_include_in_schema.py | tests/test_param_include_in_schema.py | from typing import Optional
import pytest
from fastapi import Cookie, FastAPI, Header, Path, Query
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/hidden_cookie")
async def hidden_cookie(
hidden_cookie: Optional[str] = Cookie(default=None, include_in_schema=False),
):
return {"hidden_co... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_ambiguous_params.py | tests/test_ambiguous_params.py | from typing import Annotated
import pytest
from fastapi import Depends, FastAPI, Path
from fastapi.param_functions import Query
from fastapi.testclient import TestClient
app = FastAPI()
def test_no_annotated_defaults():
with pytest.raises(
AssertionError, match="Path parameters cannot have a default val... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_oauth2.py | tests/test_security_oauth2.py | import pytest
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
reusable_oauth2 = OAuth2(
flows={
"password": {
"tokenUrl": "token",
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_validate_response_dataclass.py | tests/test_validate_response_dataclass.py | from typing import Optional
import pytest
from fastapi import FastAPI
from fastapi.exceptions import ResponseValidationError
from fastapi.testclient import TestClient
from pydantic.dataclasses import dataclass
app = FastAPI()
@dataclass
class Item:
name: str
price: Optional[float] = None
owner_ids: Opti... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_response_model_include_exclude.py | tests/test_response_model_include_exclude.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
class Model1(BaseModel):
foo: str
bar: str
class Model2(BaseModel):
ref: Model1
baz: str
class Model3(BaseModel):
name: str
age: int
ref2: Model2
app = FastAPI()
@app.get(
"/sim... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_local_docs.py | tests/test_local_docs.py | import inspect
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
def test_strings_in_generated_swagger():
sig = inspect.signature(get_swagger_ui_html)
swagger_js_url = sig.parameters.get("swagger_js_url").default # type: ignore
swagger_css_url = sig.parameters.get("swagger_css_url").d... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_openapi_schema_type.py | tests/test_openapi_schema_type.py | from typing import Optional, Union
import pytest
from fastapi.openapi.models import Schema, SchemaType
@pytest.mark.parametrize(
"type_value",
[
"array",
["string", "null"],
None,
],
)
def test_allowed_schema_type(
type_value: Optional[Union[SchemaType, list[SchemaType]]],
) -... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_http_basic_realm.py | tests/test_security_http_basic_realm.py | from base64 import b64encode
from fastapi import FastAPI, Security
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.testclient import TestClient
app = FastAPI()
security = HTTPBasic(realm="simple")
@app.get("/users/me")
def read_current_user(credentials: HTTPBasicCredentials = Security(sec... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_form_default.py | tests/test_form_default.py | from typing import Annotated, Optional
from fastapi import FastAPI, File, Form
from starlette.testclient import TestClient
app = FastAPI()
@app.post("/urlencoded")
async def post_url_encoded(age: Annotated[Optional[int], Form()] = None):
return age
@app.post("/multipart")
async def post_multi_part(
age: A... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_api_key_query_description.py | tests/test_security_api_key_query_description.py | from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyQuery
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
api_key = APIKeyQuery(name="key", description="API Key Query")
class User(BaseModel):
username: str
def get_current_user(oauth_header... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_param_class.py | tests/test_param_class.py | from typing import Optional
from fastapi import FastAPI
from fastapi.params import Param
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/items/")
def read_items(q: Optional[str] = Param(default=None)): # type: ignore
return {"q": q}
client = TestClient(app)
def test_default_param_query... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_http_digest_description.py | tests/test_security_http_digest_description.py | from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
from fastapi.testclient import TestClient
app = FastAPI()
security = HTTPDigest(description="HTTPDigest scheme")
@app.get("/users/me")
def read_current_user(credentials: HTTPAuthorizationCredentials = Securit... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_empty_router.py | tests/test_empty_router.py | import pytest
from fastapi import APIRouter, FastAPI
from fastapi.exceptions import FastAPIError
from fastapi.testclient import TestClient
app = FastAPI()
router = APIRouter()
@router.get("")
def get_empty():
return ["OK"]
app.include_router(router, prefix="/prefix")
client = TestClient(app)
def test_use_... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_custom_swagger_ui_redirect.py | tests/test_custom_swagger_ui_redirect.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
swagger_ui_oauth2_redirect_url = "/docs/redirect"
app = FastAPI(swagger_ui_oauth2_redirect_url=swagger_ui_oauth2_redirect_url)
@app.get("/items/")
async def read_items():
return {"id": "foo"}
client = TestClient(app)
def test_swagger_ui()... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_http_connection_injection.py | tests/test_http_connection_injection.py | from fastapi import Depends, FastAPI
from fastapi.requests import HTTPConnection
from fastapi.testclient import TestClient
from starlette.websockets import WebSocket
app = FastAPI()
app.state.value = 42
async def extract_value_from_http_connection(conn: HTTPConnection):
return conn.app.state.value
@app.get("/h... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_schema_ref_pydantic_v2.py | tests/test_schema_ref_pydantic_v2.py | from typing import Any
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict, Field
@pytest.fixture(name="client")
def get_client():
app = FastAPI()
class ModelWithRef(BaseModel):
ref: str =... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_repeated_parameter_alias.py | tests/test_repeated_parameter_alias.py | from fastapi import FastAPI, Path, Query, status
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/{repeated_alias}")
def get_parameters_with_repeated_aliases(
path: str = Path(..., alias="repeated_alias"),
query: str = Query(..., alias="repeated_alias"),
):
return {"path": path, "quer... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_openapi_servers.py | tests/test_openapi_servers.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
app = FastAPI(
servers=[
{"url": "/", "description": "Default, relative server"},
{
"url": "http://staging.localhost.tiangolo.com:8000",
"description": "Staging but act... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_generic_parameterless_depends.py | tests/test_generic_parameterless_depends.py | from typing import Annotated, TypeVar
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
T = TypeVar("T")
Dep = Annotated[T, Depends()]
class A:
pass
class B:
pass
@app.get("/a")
async def a(dep: Dep[A]):
return {"cls": dep.__class__.__name__}
@app.get... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_union_forms.py | tests/test_union_forms.py | from typing import Annotated, Union
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
class UserForm(BaseModel):
name: str
email: str
class CompanyForm(BaseModel):
company_name: str
industry: str
@app.post("/form-union/")
d... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_multi_body_errors.py | tests/test_multi_body_errors.py | from decimal import Decimal
from dirty_equals import IsOneOf
from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, condecimal
app = FastAPI()
class Item(BaseModel):
name: str
age: condecimal(gt=Decimal(0.0)) # type: ignore... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_dependency_paramless.py | tests/test_dependency_paramless.py | from typing import Annotated, Union
from fastapi import FastAPI, HTTPException, Security
from fastapi.security import (
OAuth2PasswordBearer,
SecurityScopes,
)
from fastapi.testclient import TestClient
app = FastAPI()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
def process_auth(
credentials:... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_additional_responses_response_class.py | tests/test_additional_responses_response_class.py | from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
class JsonApiResponse(JSONResponse):
media_type = "application/vnd.api+json"
class Error(BaseModel):
status: str
title: str
class JsonApiErro... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_union_body_discriminator.py | tests/test_union_body_discriminator.py | from typing import Annotated, Any, Union
from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, Field
from typing_extensions import Literal
def test_discriminator_pydantic_v2() -> None:
from pydantic import Tag
app = FastAPI... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_request_body_parameters_media_type.py | tests/test_request_body_parameters_media_type.py | from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
media_type = "application/vnd.api+json"
# NOTE: These are not valid JSON:API resources
# but they are fine for testing requestBody with custom media_type
class Product(BaseModel):
name: str... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_dependency_duplicates.py | tests/test_dependency_duplicates.py | from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
client = TestClient(app)
class Item(BaseModel):
data: str
def duplicate_dependency(item: Item):
return item
def dependency(item2: Item):
return item2
def sub_duplicate_depe... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_dependency_yield_scope_websockets.py | tests/test_dependency_yield_scope_websockets.py | from contextvars import ContextVar
from typing import Annotated, Any
import pytest
from fastapi import Depends, FastAPI, WebSocket
from fastapi.exceptions import FastAPIError
from fastapi.testclient import TestClient
global_context: ContextVar[dict[str, Any]] = ContextVar("global_context", default={}) # noqa: B039
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_arbitrary_types.py | tests/test_arbitrary_types.py | from typing import Annotated
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
@pytest.fixture(name="client")
def get_client():
from pydantic import (
BaseModel,
ConfigDict,
PlainSerializer,
TypeAdapter,
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_additional_response_extra.py | tests/test_additional_response_extra.py | from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
router = APIRouter()
sub_router = APIRouter()
app = FastAPI()
@sub_router.get("/")
def read_item():
return {"id": "foo"}
router.include_router(sub_router, prefix="/items")
app.include_router(router)
client = TestClient(app)
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_union_body.py | tests/test_union_body.py | from typing import Optional, Union
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: Optional[str] = None
class OtherItem(BaseModel):
price: int
@app.post("/items/")
def save_union_body(item: Union[OtherItem,... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_no_swagger_ui_redirect.py | tests/test_no_swagger_ui_redirect.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI(swagger_ui_oauth2_redirect_url=None)
@app.get("/items/")
async def read_items():
return {"id": "foo"}
client = TestClient(app)
def test_swagger_ui():
response = client.get("/docs")
assert response.status_code == 200, ... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_operations_signatures.py | tests/test_operations_signatures.py | import inspect
from fastapi import APIRouter, FastAPI
method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]
def test_signatures_consistency():
base_sig = inspect.signature(APIRouter.get)
for method_name in method_names:
router_method = getattr(APIRouter, method_name)
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_callable_endpoint.py | tests/test_callable_endpoint.py | from functools import partial
from typing import Optional
from fastapi import FastAPI
from fastapi.testclient import TestClient
def main(some_arg, q: Optional[str] = None):
return {"some_arg": some_arg, "q": q}
endpoint = partial(main, "foo")
app = FastAPI()
app.get("/")(endpoint)
client = TestClient(app)
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_dependency_security_overrides.py | tests/test_dependency_security_overrides.py | from fastapi import Depends, FastAPI, Security
from fastapi.security import SecurityScopes
from fastapi.testclient import TestClient
app = FastAPI()
def get_user(required_scopes: SecurityScopes):
return "john", required_scopes.scopes
def get_user_override(required_scopes: SecurityScopes):
return "alice", r... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_path.py | tests/test_path.py | from fastapi.testclient import TestClient
from .main import app
client = TestClient(app)
def test_text_get():
response = client.get("/text")
assert response.status_code == 200, response.text
assert response.json() == "Hello World"
def test_nonexistent():
response = client.get("/nonexistent")
a... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_response_model_invalid.py | tests/test_response_model_invalid.py | import pytest
from fastapi import FastAPI
from fastapi.exceptions import FastAPIError
class NonPydanticModel:
pass
def test_invalid_response_model_raises():
with pytest.raises(FastAPIError):
app = FastAPI()
@app.get("/", response_model=NonPydanticModel)
def read_root():
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_http_base_description.py | tests/test_security_http_base_description.py | from fastapi import FastAPI, Security
from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBase
from fastapi.testclient import TestClient
app = FastAPI()
security = HTTPBase(scheme="Other", description="Other Security Scheme")
@app.get("/users/me")
def read_current_user(credentials: HTTPAuthorization... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_openapi_route_extensions.py | tests/test_openapi_route_extensions.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/", openapi_extra={"x-custom-extension": "value"})
def route_with_extras():
return {}
client = TestClient(app)
def test_get_route():
response = client.get("/")
assert response.status_code == 200, response.... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_http_bearer_optional.py | tests/test_security_http_bearer_optional.py | from typing import Optional
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.testclient import TestClient
app = FastAPI()
security = HTTPBearer(auto_error=False)
@app.get("/users/me")
def read_current_user(
credentials: Optional[HTTPAuthor... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_inherited_custom_class.py | tests/test_inherited_custom_class.py | import uuid
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
class MyUuid:
def __init__(self, uuid_string: str):
self.uuid = uuid_string
def __str__(self):
return self.uuid
@property # type: ignore
def __class__(self... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_router_redirect_slashes.py | tests/test_router_redirect_slashes.py | from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
def test_redirect_slashes_enabled():
app = FastAPI()
router = APIRouter()
@router.get("/hello/")
def hello_page() -> str:
return "Hello, World!"
app.include_router(router)
client = TestClient(app)
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_duplicate_models_openapi.py | tests/test_duplicate_models_openapi.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
class Model(BaseModel):
pass
class Model2(BaseModel):
a: Model
class Model3(BaseModel):
c: Model
d: Model2
@app.get("/", response_model=Model3)
def f():
return {"c": {}, "d":... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_query.py | tests/test_query.py | from fastapi.testclient import TestClient
from .main import app
client = TestClient(app)
def test_query():
response = client.get("/query")
assert response.status_code == 422
assert response.json() == {
"detail": [
{
"type": "missing",
"loc": ["query", ... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_additional_responses_bad.py | tests/test_additional_responses_bad.py | import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
async def a():
pass # pragma: no cover
openapi_schema = {
"openapi": "3.1.0",
"info": {"title": "FastAPI", "versio... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_ws_dependencies.py | tests/test_ws_dependencies.py | import json
from typing import Annotated
from fastapi import APIRouter, Depends, FastAPI, WebSocket
from fastapi.testclient import TestClient
def dependency_list() -> list[str]:
return []
DepList = Annotated[list[str], Depends(dependency_list)]
def create_dependency(name: str):
def fun(deps: DepList):
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_serialize_response_dataclass.py | tests/test_serialize_response_dataclass.py | from dataclasses import dataclass
from datetime import datetime
from typing import Optional
from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
@dataclass
class Item:
name: str
date: datetime
price: Optional[float] = None
owner_ids: Optional[list[int]] = None
@app... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_application.py | tests/test_application.py | import pytest
from fastapi.testclient import TestClient
from .main import app
client = TestClient(app)
@pytest.mark.parametrize(
"path,expected_status,expected_response",
[
("/api_route", 200, {"message": "Hello World"}),
("/non_decorated_route", 200, {"message": "Hello World"}),
("/... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | true |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_response_model_sub_types.py | tests/test_response_model_sub_types.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
class Model(BaseModel):
name: str
app = FastAPI()
@app.get("/valid1", responses={"500": {"model": int}})
def valid1():
pass
@app.get("/valid2", responses={"500": {"model": list[int]}})
def valid2():
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_response_model_default_factory.py | tests/test_response_model_default_factory.py | from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
app = FastAPI()
class ResponseModel(BaseModel):
code: int = 200
message: str = Field(default_factory=lambda: "Successful operation.")
@app.get(
"/response_model_has_default_factory_return_dict",
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_api_key_query_optional.py | tests/test_security_api_key_query_optional.py | from typing import Optional
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyQuery
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
api_key = APIKeyQuery(name="key", auto_error=False)
class User(BaseModel):
username: str
def get_current... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_security_oauth2_optional_description.py | tests/test_security_oauth2_optional_description.py | from typing import Optional
import pytest
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
from fastapi.testclient import TestClient
from pydantic import BaseModel
app = FastAPI()
reusable_oauth2 = OAuth2(
flows={
"password": {
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_datetime_custom_encoder.py | tests/test_datetime_custom_encoder.py | from datetime import datetime, timezone
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
def test_pydanticv2():
from pydantic import field_serializer
class ModelWithDatetimeField(BaseModel):
dt_field: datetime
@field_serializer("dt_field")... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_include_router_defaults_overrides.py | tests/test_include_router_defaults_overrides.py | import warnings
import pytest
from fastapi import APIRouter, Depends, FastAPI, Response
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
class ResponseLevel0(JSONResponse):
media_type = "application/x-level-0"
class ResponseLevel1(JSONResponse):
media_type = "application... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | true |
fastapi/fastapi | https://github.com/fastapi/fastapi/blob/f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a/tests/test_datastructures.py | tests/test_datastructures.py | import io
from pathlib import Path
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", {})
... | python | MIT | f2687dc1bb01f4cb62eee90e656b61c38c2aaf6a | 2026-01-04T14:38:15.465144Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.