Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit f303cd7

Browse files
committed
Refactor test skipping condition for missing API key
This commit refactors the condition used to skip tests when the OPENAI_API_KEY environment variable is not set. The previous condition checked if the value of the variable was `None`, but this has been changed to a more Pythonic way of checking if the variable is not set or empty. This change improves readability and ensures that tests are skipped even when the variable is set to an empty string.
1 parent 34d91e7 commit f303cd7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def test_version(cli_runner):
99
assert aicodebot_version in result.output
1010

1111

12-
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="Skipping live tests without an API key.")
12+
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Skipping live tests without an API key.")
1313
def test_fun_fact(cli_runner):
1414
result = cli_runner.invoke(cli, ["fun-fact"])
1515
assert result.exit_code == 0
1616

1717

18-
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="Skipping live tests without an API key.")
18+
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Skipping live tests without an API key.")
1919
def test_alignment(cli_runner):
2020
result = cli_runner.invoke(cli, ["alignment"])
2121
assert result.exit_code == 0
@@ -28,7 +28,7 @@ def test_debug_success(cli_runner):
2828
assert "The command completed successfully." in result.output
2929

3030

31-
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="Skipping live tests without an API key.")
31+
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Skipping live tests without an API key.")
3232
def test_debug_failure(cli_runner):
3333
result = cli_runner.invoke(cli, ["debug", "ls", "-9"])
3434
assert result.exit_code > 0

tests/test_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os, pytest
55

66

7-
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="Skipping live tests without an API key.")
7+
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Skipping live tests without an API key.")
88
def test_commit_command(cli_runner, temp_git_repo):
99
with cli_runner.isolated_filesystem():
1010
os.chdir(temp_git_repo.working_dir) # change to the temporary repo directory
@@ -20,7 +20,7 @@ def test_commit_command(cli_runner, temp_git_repo):
2020
assert len(last_commit_message) > 10
2121

2222

23-
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="Skipping live tests without an API key.")
23+
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Skipping live tests without an API key.")
2424
def test_review(cli_runner, temp_git_repo):
2525
with cli_runner.isolated_filesystem():
2626
os.chdir(temp_git_repo.working_dir) # change to the temporary repo directory

0 commit comments

Comments
 (0)