diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..39f485bcc --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,25 @@ +name: Pre-commit Checks + +on: + push: + branches: [ main, master, develop ] # 根据您的分支名调整 + pull_request: + branches: [ main, master, develop ] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' # 指定您的Python版本 + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit on all files + run: pre-commit run --all-files diff --git a/tests/client/test_stdio.py b/tests/client/test_stdio.py index 69dad4846..21aadbac8 100644 --- a/tests/client/test_stdio.py +++ b/tests/client/test_stdio.py @@ -6,6 +6,7 @@ import time import anyio +import errno import pytest from mcp.client.session import ClientSession @@ -94,13 +95,8 @@ async def test_stdio_client_nonexistent_command(): async with stdio_client(server_params) as (_, _): pass - # The error should indicate the command was not found - error_message = str(exc_info.value) - assert ( - "nonexistent" in error_message - or "not found" in error_message.lower() - or "cannot find the file" in error_message.lower() # Windows error message - ) + # The error should indicate the command was not found (ENOENT: No such file or directory) + assert exc_info.value.errno == errno.ENOENT @pytest.mark.anyio