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

test: Fix test_config.py fails when variables are set externally in the environment #3621

Merged
merged 3 commits into from
Aug 29, 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
6 changes: 4 additions & 2 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def test_env_overrides_compat_toml(monkeypatch, default_config, temp_toml_file):
monkeypatch.setenv('WORKSPACE_BASE', 'UNDEFINED')
monkeypatch.setenv('SANDBOX_TIMEOUT', '1000')
monkeypatch.setenv('SANDBOX_USER_ID', '1002')
monkeypatch.delenv('LLM_MODEL', raising=False)

load_from_toml(default_config, temp_toml_file)

Expand Down Expand Up @@ -279,6 +280,7 @@ def test_env_overrides_sandbox_toml(monkeypatch, default_config, temp_toml_file)
monkeypatch.setenv('WORKSPACE_BASE', 'UNDEFINED')
monkeypatch.setenv('SANDBOX_TIMEOUT', '1000')
monkeypatch.setenv('SANDBOX_USER_ID', '1002')
monkeypatch.delenv('LLM_MODEL', raising=False)

load_from_toml(default_config, temp_toml_file)

Expand All @@ -305,7 +307,7 @@ def test_env_overrides_sandbox_toml(monkeypatch, default_config, temp_toml_file)
assert default_config.workspace_mount_path == os.getcwd() + '/UNDEFINED'


def test_sandbox_config_from_toml(default_config, temp_toml_file):
def test_sandbox_config_from_toml(monkeypatch, default_config, temp_toml_file):
# Test loading configuration from a new-style TOML file
with open(temp_toml_file, 'w', encoding='utf-8') as toml_file:
toml_file.write(
Expand All @@ -322,7 +324,7 @@ def test_sandbox_config_from_toml(default_config, temp_toml_file):
user_id = 1001
"""
)

monkeypatch.setattr(os, 'environ', {})
load_from_toml(default_config, temp_toml_file)
load_from_env(default_config, os.environ)
finalize_config(default_config)
Expand Down