Skip to content

Commit be35db1

Browse files
committed
Test(topstep): Add Keyring support to test fixtures
1 parent ccb42ce commit be35db1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

extensions/cpp/topstep/cython/tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ async def token(client):
2121
password = os.environ.get("QUANUX_TOPSTEP__PASSWORD")
2222
api_key = os.environ.get("QUANUX_TOPSTEP__API_KEY")
2323

24+
# Fallback to Keyring
25+
if not username:
26+
try:
27+
import keyring
28+
username = keyring.get_password("QuanuX", "QUANUX_TOPSTEP__USERNAME")
29+
password = keyring.get_password("QuanuX", "QUANUX_TOPSTEP__PASSWORD")
30+
api_key = keyring.get_password("QuanuX", "QUANUX_TOPSTEP__API_KEY")
31+
except ImportError:
32+
pass
33+
2434
if not username or not api_key:
25-
pytest.skip("Missing Topstep credentials (QUANUX_TOPSTEP__USERNAME/API_KEY)")
35+
pytest.skip("Missing Topstep credentials (Env: QUANUX_TOPSTEP__* or Keyring: QuanuX)")
2636

2737
token = await client.login(username, password or "", api_key)
2838
return token

0 commit comments

Comments
 (0)