Test import without extras (#370)

* Test import without extras

* Add import test to CI

* Use uv run
This commit is contained in:
Albert Villanova del Moral 2025-01-28 10:57:14 +01:00 committed by GitHub
parent 242a6e59c5
commit cc21135188
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -34,6 +34,11 @@ jobs:
# Run all tests separately for individual feedback
# Use 'if success() || failure()' so that all tests are run even if one failed
# See https://stackoverflow.com/a/62112985
- name: Import tests
run: |
uv run pytest ./tests/test_import.py
if: ${{ success() || failure() }}
- name: Agent tests
run: |
uv run pytest ./tests/test_agents.py

15
tests/test_import.py Normal file
View File

@ -0,0 +1,15 @@
import subprocess
def test_import_smolagents_without_extras():
# Run the import statement in an isolated virtual environment
result = subprocess.run(
["uv", "run", "--isolated", "-"], input="import smolagents", text=True, capture_output=True
)
# Check if the import was successful
assert result.returncode == 0, (
"Import failed with error: "
+ (result.stderr.splitlines()[-1] if result.stderr else "No error message")
+ "\n"
+ result.stderr
)