|
1 | | -from typing import Annotated, Any |
| 1 | +from typing import Annotated, Any, ClassVar |
2 | 2 |
|
3 | 3 | from tppt.slide_layout import ( |
4 | 4 | DefaultTitleSlide, |
@@ -80,3 +80,34 @@ class DerivedLayout(BaseLayout): |
80 | 80 | assert "derived_field" in derived_placeholders |
81 | 81 | assert derived_placeholders["base_field"] is str |
82 | 82 | assert derived_placeholders["derived_field"] is int |
| 83 | + |
| 84 | + def test_non_placeholder_fields(self): |
| 85 | + """Test that non-placeholder fields are not included in the result.""" |
| 86 | + |
| 87 | + class MixedLayout(SlideLayout): |
| 88 | + # Placeholder fields |
| 89 | + title: Placeholder[str] |
| 90 | + subtitle: Placeholder[str | None] = None |
| 91 | + |
| 92 | + # Regular fields (not placeholders) |
| 93 | + regular_str: str = "default" |
| 94 | + regular_int: int = 42 |
| 95 | + regular_list: list[str] = [] |
| 96 | + |
| 97 | + # Class variable (should also be ignored) |
| 98 | + class_var: ClassVar[bool] = True |
| 99 | + |
| 100 | + placeholders = get_placeholders(MixedLayout) |
| 101 | + |
| 102 | + # Only placeholder fields should be included |
| 103 | + assert len(placeholders) == 2 |
| 104 | + assert "title" in placeholders |
| 105 | + assert "subtitle" in placeholders |
| 106 | + |
| 107 | + # Regular fields should not be included |
| 108 | + assert "regular_str" not in placeholders |
| 109 | + assert "regular_int" not in placeholders |
| 110 | + assert "regular_list" not in placeholders |
| 111 | + |
| 112 | + # Class variables should not be included |
| 113 | + assert "class_var" not in placeholders |
0 commit comments