Skip to content

Commit

Permalink
Merge pull request #720 from python-openapi/fix/deprecation-warnings-fix
Browse files Browse the repository at this point in the history
Deprecation warnings fix
  • Loading branch information
p1c2u committed Nov 8, 2023
2 parents 8717ddf + b337eb0 commit 1f8d885
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ addopts = """
--cov-report=xml
"""
asyncio_mode = "auto"
filterwarnings = [
"error",
# falcon.media.handlers uses cgi to parse data
"ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning",
]

[tool.black]
line-length = 79
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/contrib/aiohttp/test_aiohttp_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def project_setup():


@pytest.fixture
def app(project_setup, loop):
def app(project_setup):
from aiohttpproject.__main__ import get_app

return get_app(loop=loop)
return get_app()


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import yaml
from jsonschema_path import SchemaPath

from openapi_core.contrib.falcon.middlewares import FalconOpenAPIMiddleware

openapi_spec_path = Path("tests/integration/data/v3.0/petstore.yaml")
spec_dict = yaml.load(openapi_spec_path.read_text(), yaml.Loader)
spec = SchemaPath.from_dict(spec_dict)
11 changes: 11 additions & 0 deletions tests/integration/contrib/requests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

import pytest


@pytest.fixture(autouse=True)
def disable_builtin_socket(scope="session"):
# ResourceWarning from pytest with responses 0.24.0 workaround
# See https://github.com/getsentry/responses/issues/689
with unittest.mock.patch("socket.socket"):
yield
12 changes: 5 additions & 7 deletions tests/integration/contrib/starlette/test_starlette_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_post_required_header_param_missing(self, client):

def test_post_media_type_invalid(self, client):
client.cookies.set("user", "1")
data = "data"
content = "data"
content_type = "text/html"
headers = {
"Authorization": "Basic testuser",
Expand All @@ -168,7 +168,7 @@ def test_post_media_type_invalid(self, client):
}
response = client.post(
"https://staging.gigantic-server.com/v1/pets",
data=data,
content=content,
headers=headers,
)

Expand Down Expand Up @@ -350,35 +350,33 @@ def test_get_valid(self, client):

class TestPetPhotoEndpoint(BaseTestPetstore):
def test_get_valid(self, client, data_gif):
client.cookies.set("user", "1")
headers = {
"Authorization": "Basic testuser",
"Api-Key": self.api_key_encoded,
}

cookies = {"user": "1"}
response = client.get(
"/v1/pets/1/photo",
headers=headers,
cookies=cookies,
)

assert response.content == data_gif
assert response.status_code == 200

def test_post_valid(self, client, data_gif):
client.cookies.set("user", "1")
content_type = "image/gif"
headers = {
"Authorization": "Basic testuser",
"Api-Key": self.api_key_encoded,
"Content-Type": content_type,
}

cookies = {"user": "1"}
response = client.post(
"/v1/pets/1/photo",
headers=headers,
data=data_gif,
cookies=cookies,
content=data_gif,
)

assert not response.text
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_paths_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ def test_validator_none(self):
def test_spec_validator_cls_none(self):
schema = {}

Spec.from_dict(schema, spec_validator_cls=None)
with pytest.warns(DeprecationWarning):
Spec.from_dict(schema, spec_validator_cls=None)

0 comments on commit 1f8d885

Please sign in to comment.