MCPcopy
hub / github.com/pydantic/pydantic / test_resolve_forward_ref_dataclass

Function test_resolve_forward_ref_dataclass

tests/test_forward_ref.py:465–486  ·  view source on GitHub ↗
(create_module)

Source from the content-addressed store, hash-verified

463
464
465def test_resolve_forward_ref_dataclass(create_module):
466 module = create_module(
467 # language=Python
468 """
469from __future__ import annotations
470
471from dataclasses import dataclass
472
473from pydantic import BaseModel
474from typing import Literal
475
476@dataclass
477class Base:
478 literal: Literal[1, 2]
479
480class What(BaseModel):
481 base: Base
482 """
483 )
484
485 m = module.What(base=module.Base(literal=1))
486 assert m.base.literal == 1
487
488
489def test_nested_forward_ref():

Callers

nothing calls this directly

Calls 1

create_moduleFunction · 0.85

Tested by

no test coverage detected