fix: Handle tomllib import for Python 3.10 compatibility in uvx tests
This commit is contained in:
@@ -93,7 +93,15 @@ class TestUvxProjectConfiguration:
|
|||||||
|
|
||||||
def test_pyproject_toml_has_required_uvx_fields(self):
|
def test_pyproject_toml_has_required_uvx_fields(self):
|
||||||
"""Test that pyproject.toml has all required fields for uvx support."""
|
"""Test that pyproject.toml has all required fields for uvx support."""
|
||||||
|
try:
|
||||||
import tomllib
|
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"
|
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
||||||
assert pyproject_path.exists(), "pyproject.toml should exist"
|
assert pyproject_path.exists(), "pyproject.toml should exist"
|
||||||
@@ -118,7 +126,14 @@ class TestUvxProjectConfiguration:
|
|||||||
|
|
||||||
def test_pyproject_dependencies_match_requirements(self):
|
def test_pyproject_dependencies_match_requirements(self):
|
||||||
"""Test that pyproject.toml dependencies align with requirements.txt."""
|
"""Test that pyproject.toml dependencies align with requirements.txt."""
|
||||||
|
try:
|
||||||
import tomllib
|
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
|
# Read pyproject.toml
|
||||||
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
||||||
|
|||||||
Reference in New Issue
Block a user