Skip to content

Commit 1b879dd

Browse files
Split fixtures
1 parent 306ead2 commit 1b879dd

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

tests/cli/conftest.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,45 @@ def cli_runner() -> CliRunner:
2323

2424

2525
@pytest.fixture
26-
def with_cli_env_vars() -> Generator:
26+
def with_spot_secrets() -> Generator:
2727
"""Setup some environment variables for th CLI tests"""
2828

2929
if not all(
3030
(
3131
spot_api_key := os.getenv("SPOT_API_KEY"),
3232
spot_secret_key := os.getenv("SPOT_SECRET_KEY"),
33-
futures_api_key := os.getenv("FUTURES_API_KEY"),
34-
futures_secret_key := os.getenv("FUTURES_SECRET_KEY"),
3533
),
3634
):
3735
pytest.fail("No API keys provided for CLI tests!")
3836

3937
os.environ["KRAKEN_SPOT_API_KEY"] = spot_api_key
4038
os.environ["KRAKEN_SPOT_SECRET_KEY"] = spot_secret_key
39+
40+
yield
41+
42+
for var in ("KRAKEN_SPOT_API_KEY", "KRAKEN_SPOT_SECRET_KEY"):
43+
if os.getenv(var):
44+
del os.environ[var]
45+
46+
47+
@pytest.fixture
48+
def with_futures_secrets() -> Generator:
49+
"""Setup some environment variables for the CLI tests"""
50+
51+
if not all(
52+
(
53+
futures_api_key := os.getenv("FUTURES_API_KEY"),
54+
futures_secret_key := os.getenv("FUTURES_SECRET_KEY"),
55+
),
56+
):
57+
pytest.fail("No API keys provided for CLI tests!")
58+
4159
os.environ["KRAKEN_FUTURES_API_KEY"] = futures_api_key
4260
os.environ["KRAKEN_FUTURES_SECRET_KEY"] = futures_secret_key
4361

4462
yield
4563

4664
for var in (
47-
"KRAKEN_SPOT_API_KEY",
48-
"KRAKEN_SPOT_SECRET_KEY",
4965
"KRAKEN_FUTURES_API_KEY",
5066
"KRAKEN_FUTURES_SECRET_KEY",
5167
):

tests/cli/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_cli_spot_public(cli_runner: CliRunner, args: list[str]) -> None:
6767
assert result.exit_code == 0
6868

6969

70-
@pytest.mark.usefixtures("with_cli_env_vars")
70+
@pytest.mark.usefixtures("with_spot_secrets")
7171
@pytest.mark.spot
7272
@pytest.mark.spot_auth
7373
@pytest.mark.parametrize(
@@ -122,7 +122,7 @@ def test_cli_futures_public(cli_runner: CliRunner, args: list[str]) -> None:
122122
assert result.exit_code == 0
123123

124124

125-
@pytest.mark.usefixtures("with_cli_env_vars")
125+
@pytest.mark.usefixtures("with_futures_secrets")
126126
@pytest.mark.futures
127127
@pytest.mark.futures_auth
128128
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)