From 1f37938a847c1ebf3371adcf8b63e5bb048fa868 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sat, 15 Aug 2026 08:58:20 -0700 Subject: [PATCH] fix(tests): drop SP_BASE_URL and SP_API_TOKEN from the test environment The suite sandboxes HOME and XDG_CONFIG_HOME, but the CLI also takes its base URL and token from the environment via click's envvar= (main.py:31-33). A developer with SP_BASE_URL exported -- which is what the README suggests for everyday use, and what anyone driving the CLI against the live platform will have -- fails the base-url precedence test in test_cli.py, because the test expects a saved session to win and the environment outranks it. SP_API_TOKEN is the worse of the two: a real token in the environment silently becomes test input. CI never noticed because it sets neither variable, so this only ever bites someone running the suite on a machine they also use the CLI from. --- tests/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index a393c18..16491cf 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -36,4 +36,11 @@ os.environ['HOME'] = os.path.join(SESSION_SANDBOX, 'home') os.makedirs(os.environ['HOME'], exist_ok=True) +# The CLI reads these through click's envvar= (see main.py), so a developer with +# either exported -- which is exactly what the README suggests for day-to-day use +# -- changes what the tests observe. SP_BASE_URL made a precedence test fail; a +# real SP_API_TOKEN would quietly become test input. Drop both. +for _leaking in ('SP_BASE_URL', 'SP_API_TOKEN'): + os.environ.pop(_leaking, None) + atexit.register(shutil.rmtree, SESSION_SANDBOX, True)