@@ -2841,6 +2841,75 @@ def test_main_typed_dict_additional_properties(output_file: Path) -> None:
28412841 )
28422842
28432843
2844+ @pytest .mark .skipif (
2845+ black .__version__ .split ("." )[0 ] == "22" ,
2846+ reason = "Installed black doesn't support Python version 3.11" ,
2847+ )
2848+ def test_main_typed_dict_enum_field_as_literal_none (output_file : Path ) -> None :
2849+ """Test TypedDict with enum_field_as_literal=none."""
2850+ run_main_and_assert (
2851+ input_path = JSON_SCHEMA_DATA_PATH / "enum_literal_typed_dict.json" ,
2852+ output_path = output_file ,
2853+ input_file_type = None ,
2854+ assert_func = assert_file_content ,
2855+ expected_file = "typed_dict_enum_literal_none.py" ,
2856+ extra_args = [
2857+ "--output-model-type" ,
2858+ "typing.TypedDict" ,
2859+ "--enum-field-as-literal" ,
2860+ "none" ,
2861+ "--target-python-version" ,
2862+ "3.11" ,
2863+ ],
2864+ )
2865+
2866+
2867+ @pytest .mark .skipif (
2868+ black .__version__ .split ("." )[0 ] == "22" ,
2869+ reason = "Installed black doesn't support Python version 3.11" ,
2870+ )
2871+ def test_main_typed_dict_enum_field_as_literal_one (output_file : Path ) -> None :
2872+ """Test TypedDict with enum_field_as_literal=one."""
2873+ run_main_and_assert (
2874+ input_path = JSON_SCHEMA_DATA_PATH / "enum_literal_typed_dict.json" ,
2875+ output_path = output_file ,
2876+ input_file_type = None ,
2877+ assert_func = assert_file_content ,
2878+ expected_file = "typed_dict_enum_literal_one.py" ,
2879+ extra_args = [
2880+ "--output-model-type" ,
2881+ "typing.TypedDict" ,
2882+ "--enum-field-as-literal" ,
2883+ "one" ,
2884+ "--target-python-version" ,
2885+ "3.11" ,
2886+ ],
2887+ )
2888+
2889+
2890+ @pytest .mark .skipif (
2891+ black .__version__ .split ("." )[0 ] == "22" ,
2892+ reason = "Installed black doesn't support Python version 3.11" ,
2893+ )
2894+ def test_main_typed_dict_enum_field_as_literal_all (output_file : Path ) -> None :
2895+ """Test TypedDict with enum_field_as_literal=all."""
2896+ run_main_and_assert (
2897+ input_path = JSON_SCHEMA_DATA_PATH / "enum_literal_typed_dict.json" ,
2898+ output_path = output_file ,
2899+ input_file_type = None ,
2900+ assert_func = assert_file_content ,
2901+ expected_file = "typed_dict_enum_literal_all.py" ,
2902+ extra_args = [
2903+ "--output-model-type" ,
2904+ "typing.TypedDict" ,
2905+ "--enum-field-as-literal" ,
2906+ "all" ,
2907+ "--target-python-version" ,
2908+ "3.11" ,
2909+ ],
2910+ )
2911+
2912+
28442913def test_main_dataclass_const (output_file : Path ) -> None :
28452914 """Test main function writing to dataclass with const fields."""
28462915 run_main_and_assert (
0 commit comments