@@ -8001,6 +8001,52 @@ def test_validators_requires_pydantic_v2(output_file: Path, tmp_path: Path, caps
80018001 )
80028002
80038003
8004+ def test_jsonschema_classvar_extra_pydantic_v2 (output_file : Path ) -> None :
8005+ """Test default value handling."""
8006+ run_main_and_assert (
8007+ input_path = JSON_SCHEMA_DATA_PATH / "has_classvar_extra.json" ,
8008+ output_path = output_file ,
8009+ input_file_type = "jsonschema" ,
8010+ assert_func = assert_file_content ,
8011+ expected_file = "has_classvar_extra.py" ,
8012+ extra_args = ["--output-model-type" , "pydantic_v2.BaseModel" , "--field-include-all-keys" ],
8013+ )
8014+
8015+
8016+ def test_jsonschema_classvar_extra_set_pydantic_v2 (output_file : Path ) -> None :
8017+ """Test ClassVar with set default value."""
8018+ run_main_and_assert (
8019+ input_path = JSON_SCHEMA_DATA_PATH / "has_classvar_extra_set.json" ,
8020+ output_path = output_file ,
8021+ input_file_type = "jsonschema" ,
8022+ assert_func = assert_file_content ,
8023+ expected_file = "has_classvar_extra_set.py" ,
8024+ extra_args = [
8025+ "--output-model-type" ,
8026+ "pydantic_v2.BaseModel" ,
8027+ "--field-include-all-keys" ,
8028+ "--use-unique-items-as-set" ,
8029+ ],
8030+ )
8031+
8032+
8033+ def test_jsonschema_classvar_extra_annotated_pydantic_v2 (output_file : Path ) -> None :
8034+ """Test ClassVar with use_annotated option."""
8035+ run_main_and_assert (
8036+ input_path = JSON_SCHEMA_DATA_PATH / "has_classvar_extra_annotated.json" ,
8037+ output_path = output_file ,
8038+ input_file_type = "jsonschema" ,
8039+ assert_func = assert_file_content ,
8040+ expected_file = "has_classvar_extra_annotated.py" ,
8041+ extra_args = [
8042+ "--output-model-type" ,
8043+ "pydantic_v2.BaseModel" ,
8044+ "--field-include-all-keys" ,
8045+ "--use-annotated" ,
8046+ ],
8047+ )
8048+
8049+
80048050@PYDANTIC_V2_SKIP
80058051def test_unique_items_enum_set (output_file : Path ) -> None :
80068052 """Test set with enum items does not add __hash__ to enum (already hashable)."""
0 commit comments