MCPcopy
hub / github.com/msgspec/msgspec / test_classvars_ignored

Method test_classvars_ignored

tests/unit/test_common.py:2797–2814  ·  view source on GitHub ↗
(self, proto)

Source from the content-addressed store, hash-verified

2795 assert "Expected `int`, got `str`" in str(rec.value)
2796
2797 def test_classvars_ignored(self, proto):
2798 source = """
2799 from __future__ import annotations
2800
2801 from typing import ClassVar
2802 from dataclasses import dataclass
2803
2804 @dataclass
2805 class Ex:
2806 a: int
2807 other: ClassVar[int]
2808 """
2809 with temp_module(source) as mod:
2810 msg = mod.Ex(a=1)
2811 dec = proto.Decoder(mod.Ex)
2812 res = dec.decode(proto.encode({"a": 1, "other": 2}))
2813 assert res == msg
2814 assert not hasattr(res, "other")
2815
2816 def test_initvars_forbidden(self, proto):
2817 source = """

Callers

nothing calls this directly

Calls 2

temp_moduleFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected