|
| 1 | +import pytest |
| 2 | + |
| 3 | +from pybind11_tests import cases_for_stubgen as m |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.parametrize( |
| 7 | + ("docstring", "expected"), |
| 8 | + [ |
| 9 | + ( |
| 10 | + m.pass_user_type.__doc__, |
| 11 | + 'pass_user_type(arg0: Annotated[Any, "test_cases_for_stubgen::user_type"]) -> None\n', |
| 12 | + ), |
| 13 | + ( |
| 14 | + m.return_user_type.__doc__, |
| 15 | + 'return_user_type() -> Annotated[Any, "test_cases_for_stubgen::user_type"]\n', |
| 16 | + ), |
| 17 | + ( |
| 18 | + m.MapIntUserType.keys.__doc__, |
| 19 | + "keys(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.KeysView[int]\n", |
| 20 | + ), |
| 21 | + ( |
| 22 | + m.MapIntUserType.values.__doc__, |
| 23 | + "values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[test_cases_for_stubgen::user_type]\n", |
| 24 | + ), |
| 25 | + ( |
| 26 | + m.MapIntUserType.items.__doc__, |
| 27 | + "items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, test_cases_for_stubgen::user_type]\n", |
| 28 | + ), |
| 29 | + ( |
| 30 | + m.MapUserTypeInt.keys.__doc__, |
| 31 | + "keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[test_cases_for_stubgen::user_type]\n", |
| 32 | + ), |
| 33 | + ( |
| 34 | + m.MapUserTypeInt.values.__doc__, |
| 35 | + "values(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ValuesView[int]\n", |
| 36 | + ), |
| 37 | + ( |
| 38 | + m.MapUserTypeInt.items.__doc__, |
| 39 | + "items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[test_cases_for_stubgen::user_type, int]\n", |
| 40 | + ), |
| 41 | + ( |
| 42 | + m.MapFloatUserType.keys.__doc__, |
| 43 | + "keys(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[float]\n", |
| 44 | + ), |
| 45 | + ( |
| 46 | + m.MapFloatUserType.values.__doc__, |
| 47 | + 'values(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n', |
| 48 | + ), |
| 49 | + ( |
| 50 | + m.MapFloatUserType.__iter__.__doc__, |
| 51 | + '__iter__(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[tuple[float, Annotated[Any, "test_cases_for_stubgen::user_type"]]]\n', |
| 52 | + ), |
| 53 | + ( |
| 54 | + m.MapUserTypeFloat.keys.__doc__, |
| 55 | + 'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n', |
| 56 | + ), |
| 57 | + ( |
| 58 | + m.MapUserTypeFloat.values.__doc__, |
| 59 | + "values(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[float]\n", |
| 60 | + ), |
| 61 | + ( |
| 62 | + m.MapUserTypeFloat.__iter__.__doc__, |
| 63 | + '__iter__(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[tuple[Annotated[Any, "test_cases_for_stubgen::user_type"], float]]\n', |
| 64 | + ), |
| 65 | + ], |
| 66 | +) |
| 67 | +def test_docstring(docstring, expected): |
| 68 | + assert docstring == expected |
0 commit comments