@@ -470,7 +470,11 @@ def run_main_and_assert( # noqa: PLR0912
470470 assert_func (output_path , expected_file , transform = transform )
471471
472472 if output_path is not None and not skip_code_validation :
473- _validate_output_files (output_path , extra_args , force_exec_validation = force_exec_validation )
473+ normalized_extra_args = _normalize_extra_args (
474+ extra_args ,
475+ default_output_model_type = default_output_model_type ,
476+ )
477+ _validate_output_files (output_path , normalized_extra_args , force_exec_validation = force_exec_validation )
474478
475479
476480def _parse_target_version (extra_arguments : Sequence [str ] | None ) -> tuple [int , int ] | None :
@@ -500,7 +504,7 @@ def _should_skip_exec(extra_arguments: Sequence[str] | None, *, force_exec: bool
500504 When target > runtime, compile will be skipped entirely regardless of this flag.
501505 """
502506 output_model_type = _get_argument_value (extra_arguments , "--output-model-type" )
503- is_pydantic_v1 = output_model_type is None or output_model_type == DataModelType .PydanticBaseModel .value
507+ is_pydantic_v1 = output_model_type == DataModelType .PydanticBaseModel .value
504508 if (is_pydantic_v1 and is_pydantic_v2 ()) or (
505509 output_model_type in {DataModelType .PydanticV2BaseModel .value , DataModelType .PydanticV2Dataclass .value }
506510 and not is_pydantic_v2 ()
@@ -601,6 +605,7 @@ def run_main_url_and_assert(
601605 assert_func : AssertFileContent ,
602606 expected_file : str | Path ,
603607 extra_args : Sequence [str ] | None = None ,
608+ default_output_model_type : str | None = DataModelType .PydanticBaseModel .value ,
604609 transform : Callable [[str ], str ] | None = None ,
605610 force_exec_validation : bool = False ,
606611) -> None :
@@ -613,13 +618,26 @@ def run_main_url_and_assert(
613618 assert_func: The assert_file_content function to use for verification
614619 expected_file: Expected output filename
615620 extra_args: Additional CLI arguments
621+ default_output_model_type: Output model type injected when extra_args omits
622+ --output-model-type. Set to None for tests that intentionally validate
623+ the real CLI default.
616624 transform: Optional function to transform output before comparison
617625 force_exec_validation: Run exec() even when target Python version differs from
618626 the test environment (only effective when target <= runtime).
619627 """
620628 __tracebackhide__ = True
621- return_code = _run_main_url (url , output_path , input_file_type , extra_args = extra_args )
629+ return_code = _run_main_url (
630+ url ,
631+ output_path ,
632+ input_file_type ,
633+ extra_args = extra_args ,
634+ default_output_model_type = default_output_model_type ,
635+ )
622636 _assert_exit_code (return_code , Exit .OK , f"URL: { url } " )
623637 assert_func (output_path , expected_file , transform = transform )
624638
625- _validate_output_files (output_path , extra_args , force_exec_validation = force_exec_validation )
639+ normalized_extra_args = _normalize_extra_args (
640+ extra_args ,
641+ default_output_model_type = default_output_model_type ,
642+ )
643+ _validate_output_files (output_path , normalized_extra_args , force_exec_validation = force_exec_validation )
0 commit comments