1+ import  os 
12import  shutil 
23from  filecmp  import  cmpfiles , dircmp 
34from  pathlib  import  Path 
4- from  typing  import  Dict , List , Optional , Set 
5+ import  sys 
6+ from  typing  import  Callable , Dict , List , Optional , Set 
57
68import  pytest 
79from  click .testing  import  Result 
810from  typer .testing  import  CliRunner 
911
1012from  openapi_python_client .cli  import  app 
13+ from  .end_to_end_live_tests  import  live_tests_3_x 
14+ 
1115
1216
1317def  _compare_directories (
@@ -83,8 +87,10 @@ def run_e2e_test(
8387    golden_record_path : str  =  "golden-record" ,
8488    output_path : str  =  "my-test-api-client" ,
8589    expected_missing : Optional [Set [str ]] =  None ,
90+     live_tests : Optional [Callable [[str ], None ]] =  None ,
8691) ->  Result :
87-     output_path  =  Path .cwd () /  output_path 
92+     cwd  =  Path .cwd ()
93+     output_path  =  cwd  /  output_path 
8894    shutil .rmtree (output_path , ignore_errors = True )
8995    result  =  generate (extra_args , openapi_document )
9096    gr_path  =  Path (__file__ ).parent  /  golden_record_path 
@@ -97,6 +103,13 @@ def run_e2e_test(
97103    _compare_directories (
98104        gr_path , output_path , expected_differences = expected_differences , expected_missing = expected_missing 
99105    )
106+     if  live_tests :
107+         old_path  =  sys .path .copy ()
108+         sys .path .insert (0 , str (output_path ))
109+         try :
110+             live_tests ()
111+         finally :
112+             sys .path  =  old_path 
100113
101114    import  mypy .api 
102115
@@ -131,11 +144,11 @@ def _run_command(command: str, extra_args: Optional[List[str]] = None, openapi_d
131144
132145
133146def  test_baseline_end_to_end_3_0 ():
134-     run_e2e_test ("baseline_openapi_3.0.json" , [], {})
147+     run_e2e_test ("baseline_openapi_3.0.json" , [], {},  live_tests = live_tests_3_x )
135148
136149
137150def  test_baseline_end_to_end_3_1 ():
138-     run_e2e_test ("baseline_openapi_3.1.yaml" , [], {})
151+     run_e2e_test ("baseline_openapi_3.1.yaml" , [], {},  live_tests = live_tests_3_x )
139152
140153
141154def  test_3_1_specific_features ():
0 commit comments