Skip to content

Commit 98a8f59

Browse files
chore: fix test warnings across test suite (#1468)
1 parent 6e57716 commit 98a8f59

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ log_file = "logs/pytest.log"
4646
log_file_level = "DEBUG"
4747
log_format = "%(asctime)s %(levelname)s %(message)s"
4848
log_date_format = "%Y-%m-%d %H:%M:%S"
49-
filterwarnings = [
50-
"ignore:\"@coroutine\" decorator is deprecated since Python 3.8, use \"async def\" instead:DeprecationWarning",
51-
"ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.:DeprecationWarning",
52-
"ignore:Unknown config option. asyncio_mode:pytest.PytestConfigWarning", # ignore warning when asyncio_mode is set but pytest-asyncio is not installed
53-
]
49+
filterwarnings = []
5450
asyncio_mode = "auto"
5551

5652
[tool.mypy]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
import django
4+
5+
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.adapter_tests.django.test_django_settings"
6+
django.setup()

tests/adapter_tests/django/test_django.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import os
32
from time import time
43
from urllib.parse import quote
54

@@ -29,7 +28,6 @@ class TestDjango(TestCase):
2928
base_url=mock_api_server_base_url,
3029
)
3130

32-
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.adapter_tests.django.test_django_settings"
3331
rf = RequestFactory()
3432

3533
def setUp(self):

tests/adapter_tests/starlette/test_fastapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def endpoint(req: Request):
9494
client = TestClient(api)
9595
response = client.post(
9696
"/slack/events",
97-
data=body,
97+
content=body,
9898
headers=self.build_headers(timestamp, body),
9999
)
100100
assert response.status_code == 200
@@ -138,7 +138,7 @@ async def endpoint(req: Request):
138138
client = TestClient(api)
139139
response = client.post(
140140
"/slack/events",
141-
data=body,
141+
content=body,
142142
headers=self.build_headers(timestamp, body),
143143
)
144144
assert response.status_code == 200
@@ -182,7 +182,7 @@ async def endpoint(req: Request):
182182
client = TestClient(api)
183183
response = client.post(
184184
"/slack/events",
185-
data=body,
185+
content=body,
186186
headers=self.build_headers(timestamp, body),
187187
)
188188
assert response.status_code == 200
@@ -254,7 +254,7 @@ async def endpoint(req: Request, foo: str = Depends(get_foo)):
254254
client = TestClient(api)
255255
response = client.post(
256256
"/slack/events",
257-
data=body,
257+
content=body,
258258
headers=self.build_headers(timestamp, body),
259259
)
260260
assert response.status_code == 200

tests/adapter_tests/starlette/test_starlette.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def endpoint(req: Request):
9797
client = TestClient(api)
9898
response = client.post(
9999
"/slack/events",
100-
data=body,
100+
content=body,
101101
headers=self.build_headers(timestamp, body),
102102
)
103103
assert response.status_code == 200
@@ -143,7 +143,7 @@ async def endpoint(req: Request):
143143
client = TestClient(api)
144144
response = client.post(
145145
"/slack/events",
146-
data=body,
146+
content=body,
147147
headers=self.build_headers(timestamp, body),
148148
)
149149
assert response.status_code == 200
@@ -189,7 +189,7 @@ async def endpoint(req: Request):
189189
client = TestClient(api)
190190
response = client.post(
191191
"/slack/events",
192-
data=body,
192+
content=body,
193193
headers=self.build_headers(timestamp, body),
194194
)
195195
assert response.status_code == 200

tests/adapter_tests_async/test_async_fastapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def endpoint(req: Request):
9494
client = TestClient(api)
9595
response = client.post(
9696
"/slack/events",
97-
data=body,
97+
content=body,
9898
headers=self.build_headers(timestamp, body),
9999
)
100100
assert response.status_code == 200
@@ -138,7 +138,7 @@ async def endpoint(req: Request):
138138
client = TestClient(api)
139139
response = client.post(
140140
"/slack/events",
141-
data=body,
141+
content=body,
142142
headers=self.build_headers(timestamp, body),
143143
)
144144
assert response.status_code == 200
@@ -182,7 +182,7 @@ async def endpoint(req: Request):
182182
client = TestClient(api)
183183
response = client.post(
184184
"/slack/events",
185-
data=body,
185+
content=body,
186186
headers=self.build_headers(timestamp, body),
187187
)
188188
assert response.status_code == 200
@@ -255,7 +255,7 @@ async def endpoint(req: Request, foo: str = Depends(get_foo)):
255255
client = TestClient(api)
256256
response = client.post(
257257
"/slack/events",
258-
data=body,
258+
content=body,
259259
headers=self.build_headers(timestamp, body),
260260
)
261261
assert response.status_code == 200

tests/adapter_tests_async/test_async_starlette.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def endpoint(req: Request):
9797
client = TestClient(api)
9898
response = client.post(
9999
"/slack/events",
100-
data=body,
100+
content=body,
101101
headers=self.build_headers(timestamp, body),
102102
)
103103
assert response.status_code == 200
@@ -143,7 +143,7 @@ async def endpoint(req: Request):
143143
client = TestClient(api)
144144
response = client.post(
145145
"/slack/events",
146-
data=body,
146+
content=body,
147147
headers=self.build_headers(timestamp, body),
148148
)
149149
assert response.status_code == 200
@@ -189,7 +189,7 @@ async def endpoint(req: Request):
189189
client = TestClient(api)
190190
response = client.post(
191191
"/slack/events",
192-
data=body,
192+
content=body,
193193
headers=self.build_headers(timestamp, body),
194194
)
195195
assert response.status_code == 200

tests/scenario_tests/test_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import time
33
from concurrent.futures import Executor
4-
from ssl import SSLContext
4+
import ssl
55

66
import pytest
77
from slack_sdk import WebClient
@@ -236,12 +236,12 @@ def test_none_body_no_middleware(self):
236236
assert response.body == '{"error": "unhandled request"}'
237237

238238
def test_proxy_ssl_for_respond(self):
239-
ssl = SSLContext()
239+
ssl_context = ssl.create_default_context()
240240
web_client = WebClient(
241241
token=self.valid_token,
242242
base_url=self.mock_api_server_base_url,
243243
proxy="http://proxy-host:9000/",
244-
ssl=ssl,
244+
ssl=ssl_context,
245245
)
246246
app = App(
247247
signing_secret="valid",
@@ -257,9 +257,9 @@ def test_proxy_ssl_for_respond(self):
257257
@app.event("app_mention")
258258
def handle(context: BoltContext, respond):
259259
assert context.respond.proxy == "http://proxy-host:9000/"
260-
assert context.respond.ssl == ssl
260+
assert context.respond.ssl == ssl_context
261261
assert respond.proxy == "http://proxy-host:9000/"
262-
assert respond.ssl == ssl
262+
assert respond.ssl == ssl_context
263263
result["called"] = True
264264

265265
req = BoltRequest(body=app_mention_event_body, headers={}, mode="socket_mode")

tests/scenario_tests/test_lazy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ def async2(context, say):
156156

157157
@app.middleware
158158
def set_ssl_context(context, next_):
159-
from ssl import SSLContext
159+
import ssl
160160

161161
context["foo"] = "FOO"
162162
# This causes an error when starting lazy listener executions
163-
context["ssl_context"] = SSLContext()
163+
context["ssl_context"] = ssl.create_default_context()
164164
next_()
165165

166166
# 2021-12-13 11:14:29 ERROR Failed to run a middleware middleware (error: cannot pickle 'SSLContext' object)

tests/scenario_tests_async/test_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from ssl import SSLContext
3+
import ssl
44

55
import pytest
66
from slack_sdk import WebClient
@@ -185,14 +185,14 @@ def test_installation_store_conflicts(self):
185185

186186
@pytest.mark.asyncio
187187
async def test_proxy_ssl_for_respond(self):
188-
ssl = SSLContext()
188+
ssl_ctx = ssl.create_default_context()
189189
app = AsyncApp(
190190
signing_secret="valid",
191191
client=AsyncWebClient(
192192
token=self.valid_token,
193193
base_url=self.mock_api_server_base_url,
194194
proxy="http://proxy-host:9000/",
195-
ssl=ssl,
195+
ssl=ssl_ctx,
196196
),
197197
authorize=my_authorize,
198198
)
@@ -202,9 +202,9 @@ async def test_proxy_ssl_for_respond(self):
202202
@app.event("app_mention")
203203
async def handle(context: AsyncBoltContext, respond):
204204
assert context.respond.proxy == "http://proxy-host:9000/"
205-
assert context.respond.ssl == ssl
205+
assert context.respond.ssl == ssl_ctx
206206
assert respond.proxy == "http://proxy-host:9000/"
207-
assert respond.ssl == ssl
207+
assert respond.ssl == ssl_ctx
208208
result["called"] = True
209209

210210
req = AsyncBoltRequest(body=app_mention_event_body, headers={}, mode="socket_mode")

0 commit comments

Comments
 (0)