test coverage

This commit is contained in:
Danglewood
2026-09-25 09:44:33 -07:00
parent aba09afb1c
commit 1fa72f80d7
2 changed files with 27 additions and 1 deletions

View File

@@ -1915,3 +1915,29 @@ def test_generate_model_docstring_strips_annotated_metadata_from_explicit_params
out = _render_params(limit=param)
assert "limit : int | None" in out
assert "Annotated" not in out
def test_get_field_type_bare_typevar_renders_any():
from typing import TypeVar
T = TypeVar("T")
assert DocstringGenerator.get_field_type(T, True) == "Any"
def test_generate_model_docstring_untagged_merged_description_becomes_base():
desc = "Alpha detail. (provider: a);\n Shared base text."
out = _render_params(kind=_param_with_description("kind", desc))
assert out.index("Shared base text.") < out.index("(provider: a)")
assert "Alpha detail." in out
def test_literal_choices_reads_bare_optional_and_non_literal_types():
from typing import Literal
from openbb_core.app.static.package_builder.docstring_generator import (
_literal_choices,
)
assert _literal_choices(Literal["a", "b"]) == ["a", "b"]
assert _literal_choices(Literal["a", "b"] | None) == ["a", "b"]
assert _literal_choices(int | None) == []

View File

@@ -1765,7 +1765,7 @@ def test_build_func_params_wrapped_description_keeps_spaces_and_case():
rendered = MethodDefinition.build_func_params(param_map)
namespace: dict = {}
exec( # noqa: S102
"from typing import Annotated, Literal\n"
"from typing import Annotated, Literal, Optional\n"
"from openbb_core.app.model.field import OpenBBField\n"
f"def f({rendered}): pass\n",
namespace,