Run tests for GPTSwarm
mainUse pytest to run the test suite. You can run full tests, tests using a mock LLM to avoid API costs, or specific test functions. If using Poetry, prefix commands with poetry run to automatically use the virtual environment.
Common test patterns:
- Mock LLM: Use
-m mock_llmto run tests without calling external LLM APIs. - Logging: Use the
-sflag to see logging output in the console. - Specific Tests: Use
-kto filter by function name.
# Quick no-API test (mock LLM) without logging
pytest -m mock_llm test/
# Quick no-API test (mock LLM) with logging
pytest -s -m mock_llm test/
# Standard tests without logging
pytest test/
# Standard tests with logging
pytest -s test/
# Test a specific function by name
pytest -s test/swarm/graph/test_swarm.py -k 'test_raises'
# Running via poetry
poetry run pytest -m mock_llm