(create_module)
| 551 | |
| 552 | |
| 553 | def test_class_var_as_string(create_module): |
| 554 | module = create_module( |
| 555 | # language=Python |
| 556 | """ |
| 557 | from __future__ import annotations |
| 558 | from typing import Annotated, ClassVar, ClassVar as CV |
| 559 | from pydantic import BaseModel |
| 560 | |
| 561 | class Model(BaseModel): |
| 562 | a: ClassVar[int] |
| 563 | _b: ClassVar[int] |
| 564 | _c: ClassVar[Forward] |
| 565 | _d: Annotated[ClassVar[int], ...] |
| 566 | _e: CV[int] |
| 567 | _f: Annotated[CV[int], ...] |
| 568 | # Doesn't work as of today: |
| 569 | # _g: CV[Forward] |
| 570 | |
| 571 | Forward = int |
| 572 | """ |
| 573 | ) |
| 574 | |
| 575 | assert module.Model.__class_vars__ == {'a', '_b', '_c', '_d', '_e', '_f'} |
| 576 | assert module.Model.__private_attributes__ == {} |
| 577 | |
| 578 | |
| 579 | def test_private_attr_annotation_not_evaluated() -> None: |
nothing calls this directly
no test coverage detected