Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test failure when AIRTABLE_API_KEY env is set externally #382

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ def mock_metadata(


@pytest.fixture
def run(mock_metadata):
def run(mock_metadata, monkeypatch):
default_env = {"AIRTABLE_API_KEY": "test"}

def _runner(*args: str, env: dict = default_env, fails: bool = False):
# make sure we're starting from a blank environment
monkeypatch.delenv("AIRTABLE_API_KEY", raising=False)
monkeypatch.delenv("AIRTABLE_API_KEY_FILE", raising=False)
# run the command
runner = CliRunner(env=env)
result = runner.invoke(pyairtable.cli.cli, args)
# if a test fails, show the command's output
Expand All @@ -57,6 +61,7 @@ def _runner(*args: str, env: dict = default_env, fails: bool = False):

def _runner_with_json(*args, **kwargs):
result = _runner(*args, **kwargs)
assert result.stdout, "command did not produce any output"
return json.loads(result.stdout)

_runner.json = _runner_with_json
Expand Down
Loading