Skip to content

Commit

Permalink
Add context manager to temporarily change working dir
Browse files Browse the repository at this point in the history
  • Loading branch information
salman1993 committed Sep 4, 2024
1 parent f7a080f commit 8234aac
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/toolkit/test_developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
import pytest
from goose.toolkit.base import Requirements
from goose.toolkit.developer import Developer
from contextlib import contextmanager
import os


@contextmanager
def change_dir(new_dir):
"""Context manager to temporarily change the current working directory."""
original_dir = os.getcwd()
os.chdir(new_dir)
try:
yield
finally:
os.chdir(original_dir)


@pytest.fixture
Expand Down Expand Up @@ -36,9 +49,10 @@ def test_system_prompt_with_goosehints(temp_dir, developer_toolkit):
jinja_template_content = "Hints:\n\n{% include 'README.md' %}\nEnd."
hints_file.write_text(jinja_template_content)

system_prompt = developer_toolkit.system()
expected_end = "Hints:\n\nThis is from the README.md file.\nEnd."
assert system_prompt.endswith(expected_end)
with change_dir(temp_dir):
system_prompt = developer_toolkit.system()
expected_end = "Hints:\n\nThis is from the README.md file.\nEnd."
assert system_prompt.endswith(expected_end)


def test_update_plan(developer_toolkit):
Expand Down

0 comments on commit 8234aac

Please sign in to comment.