Skip to content

Commit 1f8d885

Browse files
authored
Merge pull request #720 from python-openapi/fix/deprecation-warnings-fix
Deprecation warnings fix
2 parents 8717ddf + b337eb0 commit 1f8d885

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ addopts = """
124124
--cov-report=xml
125125
"""
126126
asyncio_mode = "auto"
127+
filterwarnings = [
128+
"error",
129+
# falcon.media.handlers uses cgi to parse data
130+
"ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning",
131+
]
127132

128133
[tool.black]
129134
line-length = 79

tests/integration/contrib/aiohttp/test_aiohttp_project.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def project_setup():
1616

1717

1818
@pytest.fixture
19-
def app(project_setup, loop):
19+
def app(project_setup):
2020
from aiohttpproject.__main__ import get_app
2121

22-
return get_app(loop=loop)
22+
return get_app()
2323

2424

2525
@pytest.fixture

tests/integration/contrib/flask/data/v3.0/flaskproject/openapi.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import yaml
44
from jsonschema_path import SchemaPath
55

6-
from openapi_core.contrib.falcon.middlewares import FalconOpenAPIMiddleware
7-
86
openapi_spec_path = Path("tests/integration/data/v3.0/petstore.yaml")
97
spec_dict = yaml.load(openapi_spec_path.read_text(), yaml.Loader)
108
spec = SchemaPath.from_dict(spec_dict)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
3+
import pytest
4+
5+
6+
@pytest.fixture(autouse=True)
7+
def disable_builtin_socket(scope="session"):
8+
# ResourceWarning from pytest with responses 0.24.0 workaround
9+
# See https://github.com/getsentry/responses/issues/689
10+
with unittest.mock.patch("socket.socket"):
11+
yield

tests/integration/contrib/starlette/test_starlette_project.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_post_required_header_param_missing(self, client):
159159

160160
def test_post_media_type_invalid(self, client):
161161
client.cookies.set("user", "1")
162-
data = "data"
162+
content = "data"
163163
content_type = "text/html"
164164
headers = {
165165
"Authorization": "Basic testuser",
@@ -168,7 +168,7 @@ def test_post_media_type_invalid(self, client):
168168
}
169169
response = client.post(
170170
"https://staging.gigantic-server.com/v1/pets",
171-
data=data,
171+
content=content,
172172
headers=headers,
173173
)
174174

@@ -350,35 +350,33 @@ def test_get_valid(self, client):
350350

351351
class TestPetPhotoEndpoint(BaseTestPetstore):
352352
def test_get_valid(self, client, data_gif):
353+
client.cookies.set("user", "1")
353354
headers = {
354355
"Authorization": "Basic testuser",
355356
"Api-Key": self.api_key_encoded,
356357
}
357358

358-
cookies = {"user": "1"}
359359
response = client.get(
360360
"/v1/pets/1/photo",
361361
headers=headers,
362-
cookies=cookies,
363362
)
364363

365364
assert response.content == data_gif
366365
assert response.status_code == 200
367366

368367
def test_post_valid(self, client, data_gif):
368+
client.cookies.set("user", "1")
369369
content_type = "image/gif"
370370
headers = {
371371
"Authorization": "Basic testuser",
372372
"Api-Key": self.api_key_encoded,
373373
"Content-Type": content_type,
374374
}
375375

376-
cookies = {"user": "1"}
377376
response = client.post(
378377
"/v1/pets/1/photo",
379378
headers=headers,
380-
data=data_gif,
381-
cookies=cookies,
379+
content=data_gif,
382380
)
383381

384382
assert not response.text

tests/unit/test_paths_spec.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def test_validator_none(self):
2222
def test_spec_validator_cls_none(self):
2323
schema = {}
2424

25-
Spec.from_dict(schema, spec_validator_cls=None)
25+
with pytest.warns(DeprecationWarning):
26+
Spec.from_dict(schema, spec_validator_cls=None)

0 commit comments

Comments
 (0)