1from collections import namedtuple 2 3import pytest 4 5from apispec import APISpec 6from apispec.ext.marshmallow import MarshmallowPlugin 7 8 9def make_spec(openapi_version): 10 ma_plugin = MarshmallowPlugin() 11 spec = APISpec( 12 title="Validation", 13 version="0.1", 14 openapi_version=openapi_version, 15 plugins=(ma_plugin,), 16 ) 17 return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( 18 spec, ma_plugin, ma_plugin.converter 19 ) 20 21 22@pytest.fixture(params=("2.0", "3.0.0")) 23def spec_fixture(request): 24 return make_spec(request.param) 25 26 27@pytest.fixture(params=("2.0", "3.0.0")) 28def spec(request): 29 return make_spec(request.param).spec 30 31 32@pytest.fixture(params=("2.0", "3.0.0")) 33def openapi(request): 34 spec = make_spec(request.param) 35 return spec.openapi 36