From e3e9e4eb55a9735b728c1c923e9aa57449ca4179 Mon Sep 17 00:00:00 2001 From: Husam Alshehadat Date: Fri, 27 Jun 2025 10:37:32 -0700 Subject: [PATCH] fix: Handle tomllib import for Python 3.10 compatibility in uvx tests --- tests/test_uvx_support.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_uvx_support.py b/tests/test_uvx_support.py index 419686b..8cb404d 100644 --- a/tests/test_uvx_support.py +++ b/tests/test_uvx_support.py @@ -93,7 +93,15 @@ class TestUvxProjectConfiguration: def test_pyproject_toml_has_required_uvx_fields(self): """Test that pyproject.toml has all required fields for uvx support.""" - import tomllib + try: + import tomllib + except ImportError: + # tomllib is only available in Python 3.11+ + # For older versions, use tomli or skip the test + try: + import tomli as tomllib + except ImportError: + pytest.skip("tomllib/tomli not available for TOML parsing") pyproject_path = Path(__file__).parent.parent / "pyproject.toml" assert pyproject_path.exists(), "pyproject.toml should exist" @@ -118,7 +126,14 @@ class TestUvxProjectConfiguration: def test_pyproject_dependencies_match_requirements(self): """Test that pyproject.toml dependencies align with requirements.txt.""" - import tomllib + try: + import tomllib + except ImportError: + # tomllib is only available in Python 3.11+ + try: + import tomli as tomllib + except ImportError: + pytest.skip("tomllib/tomli not available for TOML parsing") # Read pyproject.toml pyproject_path = Path(__file__).parent.parent / "pyproject.toml"