|
1 | 1 | import os
|
2 | 2 | import platform
|
| 3 | +import subprocess |
3 | 4 |
|
4 | 5 | import pytest
|
5 | 6 |
|
6 | 7 | from gptscript.confirm import AuthResponse
|
7 | 8 | from gptscript.frame import RunEventType, CallFrame, RunFrame, RunState, PromptFrame
|
8 | 9 | from gptscript.gptscript import GPTScript
|
| 10 | +from gptscript.install import install, gptscript_binary_name, python_bin_dir |
9 | 11 | from gptscript.opts import GlobalOptions, Options
|
10 | 12 | from gptscript.prompt import PromptResponse
|
11 | 13 | from gptscript.run import Run
|
@@ -77,6 +79,13 @@ def tool_list():
|
77 | 79 | ]
|
78 | 80 |
|
79 | 81 |
|
| 82 | +def test_install(): |
| 83 | + install() |
| 84 | + bin_name = str(python_bin_dir / gptscript_binary_name) |
| 85 | + process = subprocess.Popen([bin_name, '-v'], stdout=subprocess.PIPE, text=True) |
| 86 | + assert process.stdout.read().startswith('gptscript version ') |
| 87 | + |
| 88 | + |
80 | 89 | @pytest.mark.asyncio
|
81 | 90 | async def test_create_another_gptscript():
|
82 | 91 | g = GPTScript()
|
@@ -420,15 +429,16 @@ async def process_event(r: Run, frame: CallFrame | RunFrame | PromptFrame):
|
420 | 429 | for output in frame.output:
|
421 | 430 | event_content += output.content
|
422 | 431 |
|
423 |
| - tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory.") |
| 432 | + tool = ToolDef(tools=["sys.exec"], instructions="List the files in the current directory. If that doesn't work" |
| 433 | + "print the word FAIL.") |
424 | 434 | out = await gptscript.evaluate(tool,
|
425 | 435 | Options(confirm=True, disableCache=True),
|
426 | 436 | event_handlers=[process_event],
|
427 | 437 | ).text()
|
428 | 438 |
|
429 | 439 | assert confirm_event_found, "No confirm event"
|
430 |
| - assert "authorization error" in out, "Unexpected output: " + out |
431 |
| - assert "authorization error" in event_content, "Unexpected event output: " + event_content |
| 440 | + assert "FAIL" in out, "Unexpected output: " + out |
| 441 | + assert "FAIL" in event_content, "Unexpected event output: " + event_content |
432 | 442 |
|
433 | 443 |
|
434 | 444 | @pytest.mark.asyncio
|
|
0 commit comments