diff --git a/gptscript/install.py b/gptscript/install.py index 80bd1ca..b7effeb 100644 --- a/gptscript/install.py +++ b/gptscript/install.py @@ -150,7 +150,7 @@ def install(): # Find the extracted binary and rename/move it to the versioned name in the python bin directory extracted_binary_path = next( - output_dir.glob(gptscript_binary_name + "*"), None + output_dir.glob(gptscript_binary_name), None ) # Adjust the glob pattern if necessary if extracted_binary_path: shutil.move(str(extracted_binary_path), str(versioned_binary_path)) diff --git a/tests/test_gptscript.py b/tests/test_gptscript.py index 4b35c59..6d67547 100644 --- a/tests/test_gptscript.py +++ b/tests/test_gptscript.py @@ -1,11 +1,13 @@ import os import platform +import subprocess import pytest from gptscript.confirm import AuthResponse from gptscript.frame import RunEventType, CallFrame, RunFrame, RunState, PromptFrame from gptscript.gptscript import GPTScript +from gptscript.install import install, gptscript_binary_name, python_bin_dir from gptscript.opts import GlobalOptions, Options from gptscript.prompt import PromptResponse from gptscript.run import Run @@ -77,6 +79,13 @@ def tool_list(): ] +def test_install(): + install() + bin_name = str(python_bin_dir / gptscript_binary_name) + process = subprocess.Popen([bin_name, '-v'], stdout=subprocess.PIPE, text=True) + assert process.stdout.read().startswith('gptscript version ') + + @pytest.mark.asyncio async def test_create_another_gptscript(): g = GPTScript() @@ -420,15 +429,16 @@ async def process_event(r: Run, frame: CallFrame | RunFrame | PromptFrame): for output in frame.output: event_content += output.content - tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory.") + tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory. If that doesn't work" + "print the word FAIL.") out = await gptscript.evaluate(tool, Options(confirm=True, disableCache=True), event_handlers=[process_event], ).text() assert confirm_event_found, "No confirm event" - assert "authorization error" in out, "Unexpected output: " + out - assert "authorization error" in event_content, "Unexpected event output: " + event_content + assert "FAIL" in out, "Unexpected output: " + out + assert "FAIL" in event_content, "Unexpected event output: " + event_content @pytest.mark.asyncio