Skip to content

Commit

Permalink
Add test for add_value_to_literal
Browse files Browse the repository at this point in the history
  • Loading branch information
burnash committed Dec 12, 2024
1 parent 4a6351e commit e03801d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/common/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
is_union_type,
is_annotated,
is_callable_type,
add_value_to_literal,
)


Expand Down Expand Up @@ -293,3 +294,19 @@ def test_secret_type() -> None:

assert TSecretStrValue("x_str") == "x_str"
assert TSecretStrValue({}) == "{}"


def test_add_value_to_literal() -> None:
TestLiteral = Literal["red", "blue"]

add_value_to_literal(TestLiteral, "green")

assert get_args(TestLiteral) == ("red", "blue", "green")

add_value_to_literal(TestLiteral, "red")
assert get_args(TestLiteral) == ("red", "blue", "green")

TestSingleLiteral = Literal["red"]
add_value_to_literal(TestSingleLiteral, "green")
add_value_to_literal(TestSingleLiteral, "blue")
assert get_args(TestSingleLiteral) == ("red", "green", "blue")

0 comments on commit e03801d

Please sign in to comment.