fix(tests): patch env isolation in test_api_key_takes_priority
The test was picking up the real OPENAI_API_KEY from the shell
environment, causing it to fail on any machine with that key set.
Added @patch.dict(os.environ, {}, clear=True) so the test runs in
a clean env and exercises the file_env path as intended.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,8 +74,9 @@ class TestExtractChatgptAccountId(unittest.TestCase):
|
|||||||
|
|
||||||
class TestGetOpenaiAuth(unittest.TestCase):
|
class TestGetOpenaiAuth(unittest.TestCase):
|
||||||
|
|
||||||
|
@patch.dict(os.environ, {}, clear=True)
|
||||||
def test_api_key_takes_priority(self):
|
def test_api_key_takes_priority(self):
|
||||||
"""OPENAI_API_KEY in env file should be preferred over Codex."""
|
"""OPENAI_API_KEY in env file is used when env var is not set."""
|
||||||
file_env = {"OPENAI_API_KEY": "sk-test123"}
|
file_env = {"OPENAI_API_KEY": "sk-test123"}
|
||||||
auth = env.get_openai_auth(file_env)
|
auth = env.get_openai_auth(file_env)
|
||||||
self.assertEqual(auth.source, "api_key")
|
self.assertEqual(auth.source, "api_key")
|
||||||
|
|||||||
Reference in New Issue
Block a user