Don't send events when running CLI commands in unit tests (#600)

The `arcade dashboard` command was quite popular for the last couple
hours
This commit is contained in:
Eric Gustin 2025-10-03 16:29:53 -07:00 committed by GitHub
parent dcd0a02389
commit a84ad07b96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

29
libs/tests/conftest.py Normal file
View file

@ -0,0 +1,29 @@
"""Global test configuration for all tests.
This conftest.py is at the root of the tests directory and applies to all test modules.
"""
import os
import pytest
@pytest.fixture(autouse=True)
def disable_usage_tracking():
"""Disable CLI usage tracking for all tests.
This prevents test runs from sending analytics events to PostHog.
The fixture is autouse=True so it applies automatically to every test.
"""
original_value = os.environ.get("ARCADE_USAGE_TRACKING")
# Disable tracking
os.environ["ARCADE_USAGE_TRACKING"] = "0"
yield
# Restore original value after test
if original_value is None:
os.environ.pop("ARCADE_USAGE_TRACKING", None)
else:
os.environ["ARCADE_USAGE_TRACKING"] = original_value