File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ classifiers = [
1616 " Development Status :: 3 - Alpha" ,
1717 " Programming Language :: Python :: 3.9" ,
1818]
19+ dependencies = [
20+ " typing-extensions>=4.12.2; python_version<'3.11'"
21+ ]
1922
2023[project .urls ]
2124Homepage = " https://github.com/comfuture/function-schema"
Original file line number Diff line number Diff line change 66import subprocess
77import sys
88from pathlib import Path
9+ import pytest
910
1011
1112def test_examples_syntax ():
@@ -32,14 +33,22 @@ def test_examples_importable():
3233
3334 # Test that the file can be imported (checks imports)
3435 module_name = example_file .stem
35- spec = __import__ ('importlib.util' , fromlist = ['spec_from_file_location' ]).spec_from_file_location (module_name , example_file )
36+ import importlib .util
37+ spec = importlib .util .spec_from_file_location (module_name , example_file )
3638 try :
37- module = __import__ ('importlib.util' , fromlist = ['module_from_spec' ]).module_from_spec (spec )
38- # Don't execute the module, just load it to check imports
39+ module = importlib .util .module_from_spec (spec )
40+ # Execute the module to check imports (but not __main__ block)
41+ old_name = module .__name__
42+ module .__name__ = "__not_main__" # Prevent __main__ block execution
43+ spec .loader .exec_module (module )
44+ module .__name__ = old_name
3945 except ImportError as e :
4046 # Only fail if it's importing function_schema - other imports are optional
4147 if "function_schema" in str (e ):
4248 pytest .fail (f"Import error in { example_file } : { e } " )
49+ except Exception as e :
50+ # Other exceptions during module execution are not import issues
51+ pass
4352
4453
4554def test_cli_example_functions ():
You can’t perform that action at this time.
0 commit comments