Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/dev.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ gino-starlette==0.1.1
asyncpg

# Testing
pytest
openapi-spec-validator
pytest; python_version != '3.9'
pytest !=7.0.0; python_version == '3.9'
pytest-virtualenv
requests
asynctest
psycopg2
pyodbc
schemathesis

# Linting
flake8
Expand Down
25 changes: 25 additions & 0 deletions tests/test_schemathesis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
import schemathesis
from fastapi import FastAPI
from schemathesis.specs.openapi.schemas import BaseOpenAPISchema


@pytest.fixture()
def app_schema(client) -> BaseOpenAPISchema:
"""
Get an OpenAPI schema instance for the app created by the `client` fixture.
"""
app: FastAPI = client.app
assert client.app is not None
openapi = app.openapi()
result = schemathesis.from_dict(openapi)
return result


schema = schemathesis.from_pytest_fixture("app_schema")


@schema.parametrize()
def test_api(case, client):
"""Run tests automatically generated by schemathesis."""
case.call_and_validate(session=client)