Skip to main content

Test setup

HugBucket uses pytest with asyncio_mode = "auto" configured in pyproject.toml. This means all async def test functions run automatically in an event loop — no @pytest.mark.asyncio decorator is needed.
pyproject.toml
1

Install dev dependencies

Dev dependencies are in the dev group and are included by default with uv sync.
This installs pytest, pytest-asyncio, pytest-aiohttp, boto3, and awscli.
2

Run all unit tests

Run the full test suite, excluding integration tests that require a live HF API connection.
3

Run integration tests (optional)

Integration tests hit the live Hugging Face API and require a valid HF_TOKEN.
Integration tests create and delete real HF Storage Buckets. Use a token scoped to a test account or namespace. The conftest.py fixture skips integration tests automatically with pytest.skip() if HF_TOKEN is not set.

Running tests

Test markers

HugBucket defines a single custom marker: Apply the marker to a class or function:
Deselect integration tests in CI or offline environments:

Test structure

All tests live in the tests/ directory.

Shared fixtures (conftest.py)

Three fixtures are available to all tests:
tests/conftest.py

Writing new tests

Async tests

Because asyncio_mode = "auto" is set globally, any async def test function is automatically run under asyncio. There is no need for @pytest.mark.asyncio:

Mocking the bridge layer

Unit tests for the bridge layer mock HubClient and CASClient with AsyncMock. The pattern from test_bridge.py:
tests/test_bridge.py

Marking integration tests

Annotate any test that calls a live HF endpoint with @pytest.mark.integration. The test will be skipped automatically in environments without HF_TOKEN: