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,6 +87,7 @@ 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 :
8792 output_path = Path .cwd () / output_path
8893 shutil .rmtree (output_path , ignore_errors = True )
@@ -97,6 +102,13 @@ def run_e2e_test(
97102 _compare_directories (
98103 gr_path , output_path , expected_differences = expected_differences , expected_missing = expected_missing
99104 )
105+ if live_tests :
106+ old_path = sys .path .copy ()
107+ sys .path .insert (0 , str (output_path ))
108+ try :
109+ live_tests ()
110+ finally :
111+ sys .path = old_path
100112
101113 import mypy .api
102114
@@ -131,11 +143,11 @@ def _run_command(command: str, extra_args: Optional[List[str]] = None, openapi_d
131143
132144
133145def test_baseline_end_to_end_3_0 ():
134- run_e2e_test ("baseline_openapi_3.0.json" , [], {})
146+ run_e2e_test ("baseline_openapi_3.0.json" , [], {}, live_tests = live_tests_3_x )
135147
136148
137149def test_baseline_end_to_end_3_1 ():
138- run_e2e_test ("baseline_openapi_3.1.yaml" , [], {})
150+ run_e2e_test ("baseline_openapi_3.1.yaml" , [], {}, live_tests = live_tests_3_x )
139151
140152
141153def test_3_1_specific_features ():
0 commit comments