skip unit tests that fail in Windows (#2238)

Issue #2174
Several unit tests fail in Windows.
Added pytest attribute to skip these tests automatically.
This commit is contained in:
leo-gan 2023-04-01 12:52:21 -07:00 committed by GitHub
parent 609b14a570
commit 579ad85785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -1,4 +1,5 @@
"""Test LLM Bash functionality.""" """Test LLM Bash functionality."""
import sys
import pytest import pytest
@ -17,6 +18,9 @@ def fake_llm_bash_chain() -> LLMBashChain:
return LLMBashChain(llm=fake_llm, input_key="q", output_key="a") return LLMBashChain(llm=fake_llm, input_key="q", output_key="a")
@pytest.mark.skipif(
sys.platform.startswith("win"), reason="Test not supported on Windows"
)
def test_simple_question(fake_llm_bash_chain: LLMBashChain) -> None: def test_simple_question(fake_llm_bash_chain: LLMBashChain) -> None:
"""Test simple question that should not need python.""" """Test simple question that should not need python."""
question = "Please write a bash script that prints 'Hello World' to the console." question = "Please write a bash script that prints 'Hello World' to the console."

View File

@ -1,11 +1,17 @@
"""Test the bash utility.""" """Test the bash utility."""
import re import re
import subprocess import subprocess
import sys
from pathlib import Path from pathlib import Path
import pytest
from langchain.utilities.bash import BashProcess from langchain.utilities.bash import BashProcess
@pytest.mark.skipif(
sys.platform.startswith("win"), reason="Test not supported on Windows"
)
def test_pwd_command() -> None: def test_pwd_command() -> None:
"""Test correct functionality.""" """Test correct functionality."""
session = BashProcess() session = BashProcess()
@ -15,6 +21,9 @@ def test_pwd_command() -> None:
assert output == subprocess.check_output("pwd", shell=True).decode() assert output == subprocess.check_output("pwd", shell=True).decode()
@pytest.mark.skipif(
sys.platform.startswith("win"), reason="Test not supported on Windows"
)
def test_incorrect_command() -> None: def test_incorrect_command() -> None:
"""Test handling of incorrect command.""" """Test handling of incorrect command."""
session = BashProcess() session = BashProcess()
@ -22,6 +31,9 @@ def test_incorrect_command() -> None:
assert output == "Command 'invalid_command' returned non-zero exit status 127." assert output == "Command 'invalid_command' returned non-zero exit status 127."
@pytest.mark.skipif(
sys.platform.startswith("win"), reason="Test not supported on Windows"
)
def test_incorrect_command_return_err_output() -> None: def test_incorrect_command_return_err_output() -> None:
"""Test optional returning of shell output on incorrect command.""" """Test optional returning of shell output on incorrect command."""
session = BashProcess(return_err_output=True) session = BashProcess(return_err_output=True)
@ -29,6 +41,9 @@ def test_incorrect_command_return_err_output() -> None:
assert re.match(r"^/bin/sh:.*invalid_command.*not found.*$", output) assert re.match(r"^/bin/sh:.*invalid_command.*not found.*$", output)
@pytest.mark.skipif(
sys.platform.startswith("win"), reason="Test not supported on Windows"
)
def test_create_directory_and_files(tmp_path: Path) -> None: def test_create_directory_and_files(tmp_path: Path) -> None:
"""Test creation of a directory and files in a temporary directory.""" """Test creation of a directory and files in a temporary directory."""
session = BashProcess(strip_newlines=True) session = BashProcess(strip_newlines=True)