pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/fastapi/fastapi-cli/pull/91.patch

+# +# +# def test_schema_invalid_package() -> None: +# with changing_dir(assets_path): +# result = runner.invoke( +# app, ["schema", "broken_package/mod/app.py"] +# ) +# assert result.exit_code == 1, result.output +# assert isinstance(result.exception, ImportError) +# assert "attempted relative import beyond top-level package" in str(result.exception) + + def test_run_help() -> None: result = runner.invoke(app, ["run", "--help"]) assert result.exit_code == 0, result.output diff --git a/tests/test_utils_package.py b/tests/test_utils_package.py index 407561da..c43c9b98 100644 --- a/tests/test_utils_package.py +++ b/tests/test_utils_package.py @@ -3,7 +3,7 @@ import pytest from pytest import CaptureFixture -from fastapi_cli.discover import get_import_data +from fastapi_cli.discover import get_app, get_import_data from fastapi_cli.exceptions import FastAPICLIException from tests.utils import changing_dir @@ -169,6 +169,17 @@ def test_broken_package_dir(capsys: CaptureFixture[str]) -> None: assert "Ensure all the package directories have an __init__.py file" in captured.out +def test_get_app_broken_package_dir(capsys: CaptureFixture[str]) -> None: + with changing_dir(assets_path): + # TODO (when deprecating Python 3.8): remove ValueError + with pytest.raises((ImportError, ValueError)): + get_app(path=Path("broken_package/mod/app.py")) + + captured = capsys.readouterr() + assert "Import error:" in captured.out + assert "Ensure all the package directories have an __init__.py file" in captured.out + + def test_package_dir_no_app() -> None: with changing_dir(assets_path): with pytest.raises(FastAPICLIException) as e: From 5bf9ea891b6a421227f9f4882fb5225d4864284f Mon Sep 17 00:00:00 2001 From: "Michael \"M3\" Lasevich" Date: Mon, 6 Oct 2025 09:48:36 -0500 Subject: [PATCH 2/2] Reformat --- src/fastapi_cli/cli.py | 7 +++++-- src/fastapi_cli/discover.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fastapi_cli/cli.py b/src/fastapi_cli/cli.py index 8c04e9b9..50fdd67e 100644 --- a/src/fastapi_cli/cli.py +++ b/src/fastapi_cli/cli.py @@ -9,8 +9,11 @@ from rich.tree import Tree from typing_extensions import Annotated -from fastapi_cli.discover import get_app -from fastapi_cli.discover import get_import_data, , get_import_data_from_import_string +from fastapi_cli.discover import ( + get_app, + get_import_data, + get_import_data_from_import_string, +) from fastapi_cli.exceptions import FastAPICLIException from . import __version__ diff --git a/src/fastapi_cli/discover.py b/src/fastapi_cli/discover.py index 6a47fc3f..559c2d73 100644 --- a/src/fastapi_cli/discover.py +++ b/src/fastapi_cli/discover.py @@ -169,7 +169,7 @@ def get_import_data_from_import_string(import_string: str) -> ImportData: def get_app( - *, path: Union[Path, None] = None, app_name: Union[str, None] = None + *, path: Union[Path, None] = None, app_name: Union[str, None] = None ) -> FastAPI: """Get the FastAPI app instance from the given path and app name.""" import_data: ImportData = get_import_data(path=path, app_name=app_name) pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy