Skip to content

Commit

Permalink
Added test for Literal with multiple and repeated special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
timohl committed Jan 9, 2025
1 parent 9867800 commit 23d9551
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_pytypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ TEST_SUBMODULE(pytypes, m) {
m.def("identity_literal_percent", [](const py::typing::Literal<"\"%\""> &x) { return x; });
m.def("identity_literal_curly_open", [](const py::typing::Literal<"\"{\""> &x) { return x; });
m.def("identity_literal_curly_close", [](const py::typing::Literal<"\"}\""> &x) { return x; });
m.def("identity_literal_all_special_chars",
[](const py::typing::Literal<"\"!@!!{%}\""> &x) { return x; });
m.def("annotate_generic_containers",
[](const py::typing::List<typevar::TypeVarT> &l) -> py::typing::List<typevar::TypeVarV> {
return l;
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,10 @@ def test_literal(doc):
doc(m.identity_literal_curly_close)
== 'identity_literal_curly_close(arg0: Literal["}"]) -> Literal["}"]'
)
assert (
doc(m.identity_literal_all_special_chars)
== 'identity_literal_all_special_chars(arg0: Literal["!@!!{%}"]) -> Literal["!@!!{%}"]'
)


@pytest.mark.skipif(
Expand Down

0 comments on commit 23d9551

Please sign in to comment.