From cc21135188837e7e40a551da7314212a2b969b8d Mon Sep 17 00:00:00 2001 From: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:57:14 +0100 Subject: [PATCH] Test import without extras (#370) * Test import without extras * Add import test to CI * Use uv run --- .github/workflows/tests.yml | 5 +++++ tests/test_import.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/test_import.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b379dee..324e906 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/tests/test_import.py b/tests/test_import.py new file mode 100644 index 0000000..3253b6d --- /dev/null +++ b/tests/test_import.py @@ -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 + )