def pytest_generate_tests(metafunc): """ parametrize tests using examples() function to generate one test for each examples/ """ test_data = [(mod, mod.app.test_client(), get_specs_data(mod)) for mod in get_examples()] metafunc.parametrize('test_data', test_data, ids=lambda x: x[0].__name__)
from flask import Flask, render_template from werkzeug.serving import run_simple try: from werkzeug.middleware.dispatcher import DispatcherMiddleware except ImportError: from werkzeug.wsgi import DispatcherMiddleware from flasgger import __version__ from flasgger.utils import get_examples app = Flask(__name__) examples = OrderedDict({ '/{0}'.format(mod.__name__.split('.')[-1]): mod for mod in sorted(get_examples(), key=lambda x: x.__name__) }) @app.route('/') def index(): return render_template('flasgger.html', examples=examples, version=__version__) for example, mod in examples.items(): if hasattr(mod.app, 'swag'): mod.app.swag.config['basePath'] = example application = DispatcherMiddleware(