Foundry Local Python SDK

May 27, 2026 · View on GitHub

This test suite mirrors the structure of the JS (sdk_v2/js/test/) and C# (sdk_v2/cs/test/) SDK test suites.

Prerequisites

  1. Python 3.11+ (tested with 3.12/3.13)
  2. SDK installed in editable mode from the sdk/python directory:
    pip install -e .
    
  3. Test dependencies:
    pip install -r requirements-dev.txt
    
  4. Test model data – the test-data-shared folder must exist as a sibling of the git repo root (e.g. ../test-data-shared relative to the repo). It should contain cached models for qwen2.5-0.5b and whisper-tiny.

Running the tests

From the sdk/python directory:

# Run all tests
python -m pytest test/

# Run with verbose output
python -m pytest test/ -v

# Run a specific test file
python -m pytest test/test_catalog.py

# Run a specific test class or function
python -m pytest test/test_catalog.py::TestCatalog::test_should_list_models

# List all collected tests without running them
python -m pytest test/ --collect-only

Test structure

test/
├── conftest.py                        # Shared fixtures & config (equivalent to testUtils.ts)
├── test_foundry_local_manager.py      # FoundryLocalManager initialization (2 tests)
├── test_catalog.py                    # Catalog listing, lookup, error cases (9 tests)
├── test_model.py                      # Model caching & load/unload lifecycle (2 tests)
├── detail/
│   └── test_model_load_manager.py     # ModelLoadManager core interop & web service (5 tests)
└── openai/
    ├── test_chat_client.py            # Chat completions, streaming, error validation (7 tests)
    └── test_audio_client.py           # Audio transcription (6 tests)

Total: 31 tests

Key conventions

ConceptPython (pytest)JS (Mocha)C# (TUnit)
Shared setupconftest.py (auto-discovered)testUtils.ts (explicit import)Utils.cs ([Before(Assembly)])
Session fixture@pytest.fixture(scope="session")manual singleton[Before(Assembly)] static
Teardownyield + cleanup in fixtureafter() hook[After(Assembly)]
Skip in CI@skip_in_ci markerIS_RUNNING_IN_CI + this.skip()[SkipInCI] attribute
Expected failure@pytest.mark.xfailN/AN/A
Timeout@pytest.mark.timeout(30)this.timeout(30000)[Timeout(30000)]

CI environment detection

Tests that require the web service are skipped when either TF_BUILD=true (Azure DevOps) or GITHUB_ACTIONS=true is set.

Test models

AliasUseVariant
qwen2.5-0.5bChat completionsqwen2.5-0.5b-instruct-generic-cpu:4
whisper-tinyAudio transcriptionopenai-whisper-tiny-generic-cpu:4
qwen3-embedding-0.6bEmbeddingsqwen3-embedding-0.6b-generic-cpu:1