Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 1.09 KB

README.md

File metadata and controls

19 lines (12 loc) · 1.09 KB

Unit tests

These tests verify the SDK's internal logic in isolation, without making any real API calls. All external dependencies (Apify API, platform services) are mocked. They are fast and can be run without any environment variables or credentials.

Running

uv run poe unit-tests

Key fixtures

  • prepare_test_env / _isolate_test_environment (autouse) — Resets global state (Actor initialization, service locator, storage) and sets APIFY_LOCAL_STORAGE_DIR to a temporary directory before each test.
  • apify_client_async_patcher — Helper for patching ApifyClientAsync methods to return fixed values or replacement functions, with automatic call tracking.
  • httpserver — Local HTTP server (via pytest-httpserver) for testing HTTP interactions without real network calls.

Troubleshooting

If tests fail with SystemExit: 0 raised from _actor.py when async with Actor: exits, the virtual environment lacks the optional extras. Without Scrapy installed, the Actor exits the process on teardown. Run uv sync --all-extras (or uv run poe install-dev).