From 22ea6418038d58c69eac41123e6636cbc9cb311b Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Fri, 20 Mar 2026 12:49:40 -0400 Subject: [PATCH 1/2] chore: fix test warnings across test suite --- scripts/install.sh | 8 +++----- scripts/run_validation.sh | 2 -- scripts/uninstall_all.sh | 3 ++- tests/rtm/test_rtm_client_functional.py | 10 ++++++---- tests/slack_sdk/socket_mode/mock_socket_mode_server.py | 10 ++-------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 32a3204e8..570d7d1fc 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,13 +2,11 @@ # ./scripts/install.sh # Installs all project dependencies (testing, optional, and tools) -set -e - script_dir=$(dirname $0) cd ${script_dir}/.. pip install -U pip -pip install -U -r requirements/testing.txt \ - -U -r requirements/optional.txt \ - -U -r requirements/tools.txt +pip install -U -r requirements/testing.txt +pip install -U -r requirements/optional.txt +pip install -U -r requirements/tools.txt diff --git a/scripts/run_validation.sh b/scripts/run_validation.sh index db6eef6f9..e8742d468 100755 --- a/scripts/run_validation.sh +++ b/scripts/run_validation.sh @@ -2,8 +2,6 @@ # all: ./scripts/run_validation.sh # single: ./scripts/run_validation.sh tests/slack_sdk_async/web/test_web_client_coverage.py -set -e - script_dir=`dirname $0` cd ${script_dir}/.. diff --git a/scripts/uninstall_all.sh b/scripts/uninstall_all.sh index 71a1e51f6..a78ed0328 100755 --- a/scripts/uninstall_all.sh +++ b/scripts/uninstall_all.sh @@ -6,5 +6,6 @@ pip uninstall -y slack-sdk PACKAGES=$(pip freeze | grep -v "^-e" | sed 's/@.*//' | sed 's/\=\=.*//') # uninstall packages without exiting on a failure for package in $PACKAGES; do - pip uninstall -y $package + pip uninstall -y $package & done +wait diff --git a/tests/rtm/test_rtm_client_functional.py b/tests/rtm/test_rtm_client_functional.py index a7323342b..97d1f2eed 100644 --- a/tests/rtm/test_rtm_client_functional.py +++ b/tests/rtm/test_rtm_client_functional.py @@ -12,6 +12,8 @@ cleanup_mock_web_api_server, ) +websockets_key = web.AppKey("websockets", list) if hasattr(web, "AppKey") else "websockets" + class TestRTMClientFunctional(unittest.TestCase): def setUp(self): @@ -53,7 +55,7 @@ def tearDown(self): async def mock_server(self): app = web.Application() - app["websockets"] = [] + app[websockets_key] = [] app.router.add_get("/", self.websocket_handler) app.on_shutdown.append(self.on_shutdown) runner = web.AppRunner(app) @@ -65,16 +67,16 @@ async def websocket_handler(self, request): ws = web.WebSocketResponse() await ws.prepare(request) - request.app["websockets"].append(ws) + request.app[websockets_key].append(ws) try: async for msg in ws: await ws.send_json({"type": "message", "message_sent": msg.json()}) finally: - request.app["websockets"].remove(ws) + request.app[websockets_key].remove(ws) return ws async def on_shutdown(self, app): - for ws in set(app["websockets"]): + for ws in set(app[websockets_key]): await ws.close(code=WSCloseCode.GOING_AWAY, message="Server shutdown") # ------------------------------------------- diff --git a/tests/slack_sdk/socket_mode/mock_socket_mode_server.py b/tests/slack_sdk/socket_mode/mock_socket_mode_server.py index b08bb3252..bc8c00546 100644 --- a/tests/slack_sdk/socket_mode/mock_socket_mode_server.py +++ b/tests/slack_sdk/socket_mode/mock_socket_mode_server.py @@ -46,17 +46,11 @@ def reset_server_state(): self.reset_server_state = reset_server_state async def health(request: web.Request): - wr = web.Response() - await wr.prepare(request) - wr.set_status(200) - return wr + return web.Response(status=200) async def disconnect(request: web.Request): state["disconnect"] = True - wr = web.Response() - await wr.prepare(request) - wr.set_status(200) - return wr + return web.Response(status=200) async def link(request): connected = True From 8b3b8cff60ade50216d6a03459a92b97ea965788 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Mon, 23 Mar 2026 14:16:04 -0400 Subject: [PATCH 2/2] improve validation script --- scripts/format.sh | 1 - scripts/run_validation.sh | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/format.sh b/scripts/format.sh index 56ca68077..aa18459ab 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -5,7 +5,6 @@ script_dir=`dirname $0` cd ${script_dir}/.. if [[ "$1" != "--no-install" ]]; then - export PIP_REQUIRE_VIRTUALENV=1 pip install -U pip pip install -U -r requirements/tools.txt fi diff --git a/scripts/run_validation.sh b/scripts/run_validation.sh index e8742d468..2de6cace0 100755 --- a/scripts/run_validation.sh +++ b/scripts/run_validation.sh @@ -11,16 +11,20 @@ current_py=$(python --version | sed -E 's/Python ([0-9]+\.[0-9]+).*/\1/') ./scripts/install.sh -echo "Generating code ..." && python scripts/codegen.py --path . -echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install - -echo "Running linting checks ..." && ./scripts/lint.sh --no-install +set -e -echo "Running tests with coverage reporting ..." -test_target="${1:-tests/}" -PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ $test_target +echo "Generating code ..." && python scripts/codegen.py --path . # Run mypy type checking only on the latest supported Python version if [[ "$current_py" == "$LATEST_SUPPORTED_PY" ]]; then + echo "Running black (code formatter) ..." && ./scripts/format.sh --no-install + echo "Running linting checks ..." && ./scripts/lint.sh --no-install echo "Running mypy type checking ..." && ./scripts/run_mypy.sh --no-install +else + echo "Skipping formatting, linting, and type checking (current Python: $current_py, required: $LATEST_SUPPORTED_PY)" fi + + +echo "Running tests with coverage reporting ..." +test_target="${1:-tests/}" +PYTHONPATH=$PWD:$PYTHONPATH pytest --cov-report=xml --cov=slack_sdk/ $test_target