From a84ad07b9647e99fb1bb5c0578a4f82e22f277f5 Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:29:53 -0700 Subject: [PATCH] Don't send events when running CLI commands in unit tests (#600) The `arcade dashboard` command was quite popular for the last couple hours --- libs/tests/conftest.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libs/tests/conftest.py diff --git a/libs/tests/conftest.py b/libs/tests/conftest.py new file mode 100644 index 00000000..71eee222 --- /dev/null +++ b/libs/tests/conftest.py @@ -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