repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_default_auth_error_handler(app, client): auth = HTTPTokenAuth() @app.route('/foo') @app.auth_required(auth) def foo(): pass ...
rv.headers
assert
complex_expr
tests/test_security.py
test_default_auth_error_handler
21
null
apiflask/apiflask
import pytest from apiflask.exceptions import abort from apiflask.exceptions import HTTPError @pytest.mark.parametrize( 'kwargs', [ {}, {'message': 'missing'}, {'message': 'missing', 'detail': {'location': 'query'}}, {'message': 'missing', 'detail': {'location': 'query'}, 'head...
'missing'
assert
string_literal
tests/test_exceptions.py
test_abort
65
null
apiflask/apiflask
import json import pytest from .schemas import Foo from .schemas import Qux from apiflask.commands import spec_command def test_flask_spec_stdout(app, cli_runner): result = cli_runner.invoke(spec_command) assert 'openapi' in
result.output
assert
complex_expr
tests/test_commands.py
test_flask_spec_stdout
12
null
apiflask/apiflask
import openapi_spec_validator as osv def test_overwrite_info(app, client): app.config['INFO'] = { 'description': 'Not set', 'termsOfService': 'Not set', 'contact': {'name': 'Not set', 'url': 'Not set', 'email': 'Not set'}, 'license': {'name': 'Not set', 'url': 'Not set'}, } ...
app.config['CONTACT']
assert
complex_expr
tests/test_settings_openapi_fields.py
test_overwrite_info
98
null
apiflask/apiflask
import io from importlib.metadata import version import pytest from packaging.version import parse from werkzeug.datastructures import FileStorage from .schemas import Files from .schemas import FilesList from apiflask import Schema from apiflask.fields import Config def test_file_field(app, client): @app.post('...
200
assert
numeric_literal
tests/test_fields.py
test_file_field
24
null
apiflask/apiflask
import openapi_spec_validator as osv from flask.views import MethodView from apiflask import APIBlueprint from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_blueprint_tag(): bp = APIBlueprint('test', __name__, tag='foo') assert bp.name == 'test' assert bp.tag...
'foo'
assert
string_literal
tests/test_blueprint.py
test_blueprint_tag
19
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from flask.views import MethodView from flask.views import View from .schemas import Foo from apiflask import APIBlueprint from apiflask import HTTPTokenAuth def test_route_on_method_view(app, client): @app.route('/') class Foo(MethodView): def get(se...
b'put'
assert
string_literal
tests/test_route.py
test_route_on_method_view
54
null
apiflask/apiflask
import sys import openapi_spec_validator as osv import pytest from apiflask import APIFlask pydantic = pytest.importorskip('pydantic') BaseModel = pydantic.BaseModel Field = pydantic.Field class TestPydanticIntegration: def test_query_parameters_with_pydantic(self): """Test query parameter validation w...
2
assert
numeric_literal
tests/test_pydantic_integration.py
test_query_parameters_with_pydantic
TestPydanticIntegration
263
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_async_error_processor(app, client): @app.error_processor async def custom_error_processor(e): return {'foo': 'test'}, e.status_code, e.headers rv = client.get('/foo') assert rv.status_co...
404
assert
numeric_literal
tests/test_async.py
test_async_error_processor
23
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_async_doc_input_and_output_decorator(app, client): @app.post('/') @app.doc(summary='Test Root Endpoint') @app.input(Foo) @app.output(Foo) async def index(json_data): return json_data ...
payload
assert
variable
tests/test_async.py
test_async_doc_input_and_output_decorator
108
null
apiflask/apiflask
import openapi_spec_validator as osv from flask.views import MethodView from apiflask import APIBlueprint from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_blueprint_enable_openapi(app, client): auth = HTTPBasicAuth() @app.get('/hello') @app.auth_required(au...
200
assert
numeric_literal
tests/test_blueprint.py
test_blueprint_enable_openapi
47
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from .schemas import HTTPError from .schemas import ValidationError from apiflask.schemas import EmptySchema from apiflask.schemas import http_error_schema from apiflask.security import HTTPBasicAuth def test_response_description_config(app, ...
'Success'
assert
string_literal
tests/test_settings_response_customization.py
test_response_description_config
43
null
apiflask/apiflask
import openapi_spec_validator as osv def test_info(app, client): app.config['INFO'] = { 'description': 'My API', 'termsOfService': 'http://example.com', 'contact': { 'name': 'API Support', 'url': 'http://www.example.com/support', 'email': 'support@example...
app.config['INFO']['contact']
assert
complex_expr
tests/test_settings_openapi_fields.py
test_info
69
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import DelimitedListQuery def test_query_delimited_list_support(app, client): @app.route('/users') @app.input(DelimitedListQuery, location='query') def get_users(query_data): """Get Users""" return query_data['tags'] rv = client.get('...
'form'
assert
string_literal
tests/test_openapi_parameters.py
test_query_delimited_list_support
17
null
apiflask/apiflask
import sys import openapi_spec_validator as osv import pytest from apiflask import APIFlask pydantic = pytest.importorskip('pydantic') BaseModel = pydantic.BaseModel Field = pydantic.Field class TestPydanticIntegration: def test_output_decorator_with_pydantic_model(self): """Test @app.output decorator ...
1
assert
numeric_literal
tests/test_pydantic_integration.py
test_output_decorator_with_pydantic_model
TestPydanticIntegration
57
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from .schemas import Header from .schemas import Pagination from .schemas import Query def test_path_arguments_order(app, client): @app.route('/<foo>/bar') @app.input(Query, location='query') @app.output(Foo) def path_and_query(foo, query_d...
'id'
assert
string_literal
tests/test_openapi_paths.py
test_path_arguments_order
181
null
apiflask/apiflask
import pytest from apiflask.exceptions import abort from apiflask.exceptions import HTTPError @pytest.mark.parametrize( 'kwargs', [ {}, {'message': 'bad'}, {'message': 'bad', 'detail': {'location': 'json'}}, {'message': 'bad', 'detail': {'location': 'json'}, 'headers': {'X-FOO'...
'bad'
assert
string_literal
tests/test_exceptions.py
test_httperror
30
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer @pytest.mark...
spec
assert
variable
tests/test_openapi_basic.py
test_get_spec
65
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_async_view(app, client): @app.get('/') async def index(): return {'message': 'hello'} rv = client.get('/') assert rv.status_code == 200 assert rv.json['message'] ==
'hello'
assert
string_literal
tests/test_async.py
test_async_view
14
null
apiflask/apiflask
import os import sys from importlib import metadata, reload import re import pytest from packaging.version import Version full_examples = [ 'basic', 'orm', 'cbv', 'openapi/basic', 'blueprint_tags', 'base_response/marshmallow', 'base_response/pydantic', 'pydantic', 'dataclass', ] e...
20
assert
numeric_literal
examples/test_examples.py
test_get_pets_pagination
177
null
apiflask/apiflask
from importlib import metadata import openapi_spec_validator as osv import pytest from flask.views import MethodView from packaging.version import Version from apiflask import APIBlueprint from apiflask.security import APIKeyCookieAuth from apiflask.security import APIKeyHeaderAuth from apiflask.security import APIKe...
401
assert
numeric_literal
tests/test_decorator_auth_required.py
test_auth_required
56
null
apiflask/apiflask
import pytest from apiflask.exceptions import abort from apiflask.exceptions import HTTPError @pytest.mark.parametrize( 'kwargs', [ {}, {'message': 'bad'}, {'message': 'bad', 'detail': {'location': 'json'}}, {'message': 'bad', 'detail': {'location': 'json'}, 'headers': {'X-FOO'...
400
assert
numeric_literal
tests/test_exceptions.py
test_httperror
26
null
apiflask/apiflask
import importlib import openapi_spec_validator as osv import pytest from apiflask import APIBlueprint @pytest.mark.parametrize('tag', ['test', {'name': 'test'}]) def test_path_tags_with_blueprint_tag(app, client, tag): bp = APIBlueprint('foo', __name__, tag=tag) @bp.get('/') def foo(): pass ...
['test']
assert
collection
tests/test_openapi_tags.py
test_path_tags_with_blueprint_tag
137
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import Schema from apiflask.fields import Field from apiflask.fields import Integer from apiflask.fields import String def test_body_schema_registration_with_reference(app, client): """Test that body schemas are registered and referenced correctly.""" @app.p...
schema
assert
variable
tests/test_decoupling_integration.py
test_body_schema_registration_with_reference
70
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask def test_info_attribute(app, client): assert app.info is None app.info = { 'description': 'My API', 'termsOfService': 'http://example.com', 'contact': { 'name': 'API Support', 'url': 'http://www...
app.info['license']
assert
complex_expr
tests/test_openapi_info.py
test_info_attribute
59
null
apiflask/apiflask
import pytest from marshmallow import fields from marshmallow import Schema from marshmallow import ValidationError from apiflask.schema_adapters import registry from apiflask.schema_adapters.marshmallow import MarshmallowAdapter class TestMarshmallowAdapter: def test_serialize_output_many(self): """Test...
'Bella'
assert
string_literal
tests/test_schema_adapters.py
test_serialize_output_many
TestMarshmallowAdapter
211
null
apiflask/apiflask
import os import sys from importlib import metadata, reload import re import pytest from packaging.version import Version full_examples = [ 'basic', 'orm', 'cbv', 'openapi/basic', 'blueprint_tags', 'base_response/marshmallow', 'base_response/pydantic', 'pydantic', 'dataclass', ] e...
204
assert
numeric_literal
examples/test_examples.py
test_delete_pet
158
null
apiflask/apiflask
import openapi_spec_validator as osv def test_openapi_fields(app, client): openapi_version = '3.0.2' description = 'My API' tags = [ { 'name': 'foo', 'description': 'some description for foo', 'externalDocs': { 'description': 'Find more info about...
contact
assert
variable
tests/test_settings_openapi_fields.py
test_openapi_fields
47
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from apiflask import APIKeyCookieAuth from apiflask import APIKeyHeaderAuth from apiflask import APIKeyQueryAuth from apiflask import HTTPBasicAuth from apiflask import HTTPTokenAuth from apiflask.security import MultiAuth def test_multi_auth(app, client): basic_...
rv.headers
assert
complex_expr
tests/test_openapi_security.py
test_multi_auth
256
null
apiflask/apiflask
import json import pytest from .schemas import Foo from .schemas import Qux from apiflask.commands import spec_command def test_flask_spec_quiet(app, cli_runner): result = cli_runner.invoke(spec_command, ['--quiet']) assert result.output ==
''
assert
string_literal
tests/test_commands.py
test_flask_spec_quiet
79
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_output_on_async_view(app, client): @app.get('/foo') @app.output(Foo) async def foo(): return {'id': 1, 'name': 'foo'} rv = client.get('/foo') assert rv.status_code == 200 assert r...
'foo'
assert
string_literal
tests/test_async.py
test_output_on_async_view
83
null
apiflask/apiflask
from marshmallow import fields from marshmallow import Schema from marshmallow import validate from apiflask.openapi_adapters import get_unique_schema_name from apiflask.openapi_adapters import OpenAPIHelper class TestOpenAPIHelper: def test_schema_to_parameters_query(self): """Test schema_to_parameters ...
2
assert
numeric_literal
tests/test_openapi_adapters.py
test_schema_to_parameters_query
TestOpenAPIHelper
114
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from .schemas import Header from .schemas import Pagination from .schemas import Query def test_spec_path_parameters_registration(app, client): @app.route('/strings/<some_string>') @app.output(Foo) def get_string(some_string): pass ...
'path'
assert
string_literal
tests/test_openapi_paths.py
test_spec_path_parameters_registration
59
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer def test_aut...
'empty'
assert
string_literal
tests/test_openapi_basic.py
test_auto_200_response
240
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_bypass_default_auth_error_handler(): app = APIFlask(__name__, json_errors=False) auth = HTTPTokenAuth() @app.route('/foo') @app.auth_requ...
rv.data
assert
complex_expr
tests/test_security.py
test_bypass_default_auth_error_handler
36
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from .schemas import Header from .schemas import Pagination from .schemas import Query def test_register_validation_error_response(app, client): error_code = str(app.config['VALIDATION_ERROR_STATUS_CODE']) @app.post('/foo') @app.input(Foo) ...
None
assert
none_literal
tests/test_openapi_paths.py
test_register_validation_error_response
232
null
apiflask/apiflask
from importlib import metadata import openapi_spec_validator as osv import pytest from flask.views import MethodView from packaging.version import Version from apiflask import APIBlueprint from apiflask.security import APIKeyCookieAuth from apiflask.security import APIKeyHeaderAuth from apiflask.security import APIKe...
403
assert
numeric_literal
tests/test_decorator_auth_required.py
test_auth_required
63
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer def test_spe...
5
assert
numeric_literal
tests/test_openapi_basic.py
test_spec_schemas
151
null
apiflask/apiflask
import pytest from apiflask import APIFlask def test_disable_openapi_with_enable_openapi_arg(app): assert app.enable_openapi app = APIFlask(__name__, enable_openapi=False) assert app.enable_openapi is
False
assert
bool_literal
tests/test_openapi_blueprint.py
test_disable_openapi_with_enable_openapi_arg
102
null
apiflask/apiflask
from marshmallow import fields from marshmallow import Schema from marshmallow import validate from apiflask.openapi_adapters import get_unique_schema_name from apiflask.openapi_adapters import OpenAPIHelper class TestOpenAPIHelper: def test_schema_to_parameters_query(self): """Test schema_to_parameters ...
False
assert
bool_literal
tests/test_openapi_adapters.py
test_schema_to_parameters_query
TestOpenAPIHelper
122
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from flask.views import MethodView from packaging.version import Version from .conftest import APISPEC_VERSION from .schemas import CustomHTTPError from .schemas import Foo def test_doc_responses_custom_spec(app, client): response_spec = { 'description': ...
schema
assert
variable
tests/test_decorator_doc.py
test_doc_responses_custom_spec
279
null
apiflask/apiflask
from dataclasses import dataclass import openapi_spec_validator as osv from flask import make_response from flask.views import MethodView from packaging.version import Version from .conftest import APISPEC_VERSION from .schemas import Foo from .schemas import Query from apiflask import Schema from apiflask.fields imp...
1
assert
numeric_literal
tests/test_decorator_output.py
test_response_content_type
343
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from apiflask import Schema from apiflask.fields import Field from apiflask.fields import Integer from apiflask.fields import String def test_output_base_response(app, client): app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse @app.g...
123
assert
numeric_literal
tests/test_base_response.py
test_output_base_response
57
null
apiflask/apiflask
import pytest from apiflask import APIFlask def test_openapi_blueprint_url_prefix(app): assert app.openapi_blueprint_url_prefix is None prefix = '/api' app = APIFlask(__name__, openapi_blueprint_url_prefix=prefix) assert app.openapi_blueprint_url_prefix ==
prefix
assert
variable
tests/test_openapi_blueprint.py
test_openapi_blueprint_url_prefix
145
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from apiflask import APIKeyCookieAuth from apiflask import APIKeyHeaderAuth from apiflask import APIKeyQueryAuth from apiflask import HTTPBasicAuth from apiflask import HTTPTokenAuth from apiflask.security import MultiAuth def test_multiple_auth_names(app, client): ...
1
assert
numeric_literal
tests/test_openapi_security.py
test_multiple_auth_names
194
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from apiflask import Schema from apiflask.fields import Field from apiflask.fields import Integer from apiflask.fields import String def test_output_base_response(app, client): app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse @app.g...
rv.json
assert
complex_expr
tests/test_base_response.py
test_output_base_response
54
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from .schemas import HTTPError from .schemas import ValidationError from apiflask.schemas import EmptySchema from apiflask.schemas import http_error_schema from apiflask.security import HTTPBasicAuth @pytest.mark.parametrize('schema', [http_e...
rv.json['components']['schemas']
assert
complex_expr
tests/test_settings_response_customization.py
test_validation_error_schema
82
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer def test_spe...
'3.0.2'
assert
string_literal
tests/test_openapi_basic.py
test_spec_processor
34
null
apiflask/apiflask
import pytest from apiflask import APIFlask def test_docs_path(app): assert app.docs_path app = APIFlask(__name__, docs_path=None) assert app.docs_path is None rules = list(app.url_map.iter_rules()) bp_endpoints = [rule.endpoint for rule in rules if rule.endpoint.startswith('openapi')] asse...
1
assert
numeric_literal
tests/test_openapi_blueprint.py
test_docs_path
51
null
apiflask/apiflask
import io import openapi_spec_validator as osv import pytest from flask.views import MethodView from packaging.version import Version from werkzeug.datastructures import FileStorage from .conftest import APISPEC_VERSION from .schemas import Bar from .schemas import EnumPathParameter from .schemas import Files from .s...
422
assert
numeric_literal
tests/test_decorator_input.py
test_input_with_query_location
76
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_auth_required_on_async_view(app, client): auth = HTTPTokenAuth() @app.get('/') @app.auth_required(auth) async def index(): pass rv = client.get('/') assert rv.status_code ==
401
assert
numeric_literal
tests/test_async.py
test_auth_required_on_async_view
48
null
apiflask/apiflask
import openapi_spec_validator as osv def test_info(app, client): app.config['INFO'] = { 'description': 'My API', 'termsOfService': 'http://example.com', 'contact': { 'name': 'API Support', 'url': 'http://www.example.com/support', 'email': 'support@example...
app.config['INFO']['description']
assert
complex_expr
tests/test_settings_openapi_fields.py
test_info
67
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer @app.spe...
'3.0.3'
assert
string_literal
tests/test_openapi_basic.py
edit_spec
24
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask def test_info_title_and_version(app): assert app.title == 'APIFlask' assert app.version == '0.1.0' app = APIFlask(__name__, title='Foo', version='1.0') assert app.spec['info']['title'] == 'Foo' assert app.spec['info']['version'] ...
'1.0'
assert
string_literal
tests/test_openapi_info.py
test_info_title_and_version
12
null
apiflask/apiflask
import pytest from apiflask import APIFlask def test_disable_openapi_with_enable_openapi_arg(app): assert app.enable_openapi app = APIFlask(__name__, enable_openapi=False) assert app.enable_openapi is False rules = list(app.url_map.iter_rules()) bp_endpoints = [rule.endpoint for rule in rules if...
0
assert
numeric_literal
tests/test_openapi_blueprint.py
test_disable_openapi_with_enable_openapi_arg
106
null
apiflask/apiflask
import pytest from apiflask import get_reason_phrase from apiflask import pagination_builder from apiflask import PaginationModel from apiflask import PaginationSchema def test_pagination_builder(app, client): class Pagination: page = 1 per_page = 20 pages = 100 total = 2000 ...
rv.json
assert
complex_expr
tests/test_helpers.py
test_pagination_builder
57
null
apiflask/apiflask
import os import sys from importlib import metadata, reload import re import pytest from packaging.version import Version full_examples = [ 'basic', 'orm', 'cbv', 'openapi/basic', 'blueprint_tags', 'base_response/marshmallow', 'base_response/pydantic', 'pydantic', 'dataclass', ] e...
3
assert
numeric_literal
examples/test_examples.py
test_get_pets
87
null
apiflask/apiflask
import pytest from marshmallow import fields from marshmallow import Schema from marshmallow import ValidationError from apiflask.schema_adapters import registry from apiflask.schema_adapters.marshmallow import MarshmallowAdapter class TestMarshmallowAdapter: def test_serialize_output(self): """Test seri...
7
assert
numeric_literal
tests/test_schema_adapters.py
test_serialize_output
TestMarshmallowAdapter
198
null
apiflask/apiflask
import json import pytest from apiflask import APIFlask from apiflask.commands import spec_command @pytest.mark.parametrize('format', ['yaml', 'yml', 'json']) def test_spec_format(app, client, cli_runner, format): app.config['SPEC_FORMAT'] = format result = cli_runner.invoke(spec_command) rv = client.ge...
rv.data
assert
complex_expr
tests/test_settings_openapi_spec.py
test_spec_format
46
null
apiflask/apiflask
from marshmallow import fields from marshmallow import Schema from marshmallow import validate from apiflask.openapi_adapters import get_unique_schema_name from apiflask.openapi_adapters import OpenAPIHelper class TestOpenAPIHelper: def test_schema_to_parameters_query(self): """Test schema_to_parameters ...
'name'
assert
string_literal
tests/test_openapi_adapters.py
test_schema_to_parameters_query
TestOpenAPIHelper
115
null
apiflask/apiflask
import json import openapi_spec_validator as osv import pytest from flask import request from .schemas import Bar from .schemas import Baz from .schemas import Foo from apiflask import APIBlueprint from apiflask import Schema from apiflask.commands import spec_command from apiflask.fields import Integer def test_spe...
200
assert
numeric_literal
tests/test_openapi_basic.py
test_spec_processor
32
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_default_auth_error_handler(app, client): auth = HTTPTokenAuth() @app.route('/foo') @app.auth_required(auth) def foo(): pass ...
rv.json
assert
complex_expr
tests/test_security.py
test_default_auth_error_handler
19
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from apiflask import Schema from apiflask.fields import Field from apiflask.fields import Integer from apiflask.fields import String def test_output_base_response(app, client): app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse @app.g...
200
assert
numeric_literal
tests/test_base_response.py
test_output_base_response
52
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from apispec import BasePlugin from flask import Blueprint from flask.views import MethodView from .schemas import Bar from .schemas import Foo from .schemas import Pagination from apiflask import APIBlueprint from apiflask import APIFlask from apiflask import Schema ...
200
assert
numeric_literal
tests/test_app.py
test_error_callback
144
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from .schemas import Foo from .schemas import ResponseHeader from apiflask.fields import Boolean from apiflask.fields import Integer from apiflask.fields import List from apiflask.fields import Number from apiflask.fields import String def test_spec_with_empty_header...
{}
assert
collection
tests/test_openapi_headers.py
test_spec_with_empty_headers
67
null
apiflask/apiflask
import io import openapi_spec_validator as osv import pytest from flask.views import MethodView from packaging.version import Version from werkzeug.datastructures import FileStorage from .conftest import APISPEC_VERSION from .schemas import Bar from .schemas import EnumPathParameter from .schemas import Files from .s...
1
assert
numeric_literal
tests/test_decorator_input.py
test_input_with_path_location
245
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from flask.views import MethodView from .schemas import Foo from .schemas import Query from apiflask import APIBlueprint from apiflask.security import HTTPBasicAuth @pytest.mark.parametrize('config_value', [True, False]) def test_auto_path_summary(app, client, config...
'Get Bar'
assert
string_literal
tests/test_settings_auto_behaviour.py
test_auto_path_summary
75
null
apiflask/apiflask
import os import sys from importlib import metadata, reload import re import pytest from packaging.version import Version full_examples = [ 'basic', 'orm', 'cbv', 'openapi/basic', 'blueprint_tags', 'base_response/marshmallow', 'base_response/pydantic', 'pydantic', 'dataclass', ] e...
5
assert
numeric_literal
examples/test_examples.py
test_get_pets_pagination
179
null
apiflask/apiflask
import json import pytest from .schemas import Foo from .schemas import Qux from apiflask.commands import spec_command @pytest.mark.parametrize('format', ['json', 'yaml', 'yml', 'foo']) def test_flask_spec_format(app, cli_runner, format, tmp_path): local_spec_path = tmp_path / 'openapi.json' @app.get('/') ...
file_result.output
assert
complex_expr
tests/test_commands.py
test_flask_spec_format
53
null
apiflask/apiflask
import openapi_spec_validator as osv def test_openapi_fields(app, client): openapi_version = '3.0.2' description = 'My API' tags = [ { 'name': 'foo', 'description': 'some description for foo', 'externalDocs': { 'description': 'Find more info about...
license
assert
variable
tests/test_settings_openapi_fields.py
test_openapi_fields
48
null
apiflask/apiflask
from marshmallow import fields from marshmallow import Schema from marshmallow import validate from apiflask.openapi_adapters import get_unique_schema_name from apiflask.openapi_adapters import OpenAPIHelper class TestOpenAPIHelper: def test_get_marshmallow_plugin(self): """Test get_marshmallow_plugin me...
None
assert
none_literal
tests/test_openapi_adapters.py
test_get_marshmallow_plugin
TestOpenAPIHelper
60
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from .schemas import Header from .schemas import Pagination from .schemas import Query def test_parameters_registration(app, client): @app.route('/foo') @app.input(Query, location='query') @app.output(Foo) def foo(query_data): pass ...
4
assert
numeric_literal
tests/test_openapi_paths.py
test_parameters_registration
207
null
apiflask/apiflask
import io from importlib.metadata import version import pytest from packaging.version import parse from werkzeug.datastructures import FileStorage from .schemas import Files from .schemas import FilesList from apiflask import Schema from apiflask.fields import Config def test_multiple_file_field(app, client): @a...
{'images': True}
assert
collection
tests/test_fields.py
test_multiple_file_field
96
null
apiflask/apiflask
import io from importlib.metadata import version import pytest from packaging.version import parse from werkzeug.datastructures import FileStorage from .schemas import Files from .schemas import FilesList from apiflask import Schema from apiflask.fields import Config def test_file_field(app, client): @app.post('...
422
assert
numeric_literal
tests/test_fields.py
test_file_field
46
null
apiflask/apiflask
import openapi_spec_validator as osv from flask.views import MethodView from apiflask import APIBlueprint from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_blueprint_object(): bp = APIBlueprint('test', __name__) assert bp.name == 'test' assert hasattr(bp, 'ta...
None
assert
none_literal
tests/test_blueprint.py
test_blueprint_object
13
null
apiflask/apiflask
import pytest from marshmallow import fields from marshmallow import Schema from marshmallow import ValidationError from apiflask.schema_adapters import registry from apiflask.schema_adapters.marshmallow import MarshmallowAdapter class TestMarshmallowAdapter: def test_serialize_output(self): """Test seri...
output
assert
variable
tests/test_schema_adapters.py
test_serialize_output
TestMarshmallowAdapter
200
null
apiflask/apiflask
import openapi_spec_validator as osv import pytest from apispec import BasePlugin from flask import Blueprint from flask.views import MethodView from .schemas import Bar from .schemas import Foo from .schemas import Pagination from apiflask import APIBlueprint from apiflask import APIFlask from apiflask import Schema ...
1
assert
numeric_literal
tests/test_app.py
test_view_function_arguments_order
108
null
apiflask/apiflask
import openapi_spec_validator as osv from apiflask import APIFlask def test_info_title_and_version(app): assert app.title == 'APIFlask' assert app.version == '0.1.0' app = APIFlask(__name__, title='Foo', version='1.0') assert app.spec['info']['title'] ==
'Foo'
assert
string_literal
tests/test_openapi_info.py
test_info_title_and_version
11
null
apiflask/apiflask
import io from importlib.metadata import version import pytest from packaging.version import parse from werkzeug.datastructures import FileStorage from .schemas import Files from .schemas import FilesList from apiflask import Schema from apiflask.fields import Config def test_file_field(app, client): @app.post('...
'binary'
assert
string_literal
tests/test_fields.py
test_file_field
27
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from .schemas import Header from .schemas import Pagination from .schemas import Query def test_spec_path_parameters_registration(app, client): @app.route('/strings/<some_string>') @app.output(Foo) def get_string(some_string): pass ...
'string'
assert
string_literal
tests/test_openapi_paths.py
test_spec_path_parameters_registration
63
null
apiflask/apiflask
import openapi_spec_validator as osv from flask.views import MethodView from apiflask import APIBlueprint from apiflask.security import HTTPBasicAuth from apiflask.security import HTTPTokenAuth def test_blueprint_enable_openapi(app, client): auth = HTTPBasicAuth() @app.get('/hello') @app.auth_required(au...
rv.json['paths']
assert
complex_expr
tests/test_blueprint.py
test_blueprint_enable_openapi
50
null
apiflask/apiflask
import openapi_spec_validator as osv from .schemas import Foo from apiflask import HTTPTokenAuth def test_async_error_processor(app, client): @app.error_processor async def custom_error_processor(e): return {'foo': 'test'}, e.status_code, e.headers rv = client.get('/foo') assert rv.status_cod...
'test'
assert
string_literal
tests/test_async.py
test_async_error_processor
24
null
apiflask/apiflask
from dataclasses import dataclass import openapi_spec_validator as osv from flask import make_response from flask.views import MethodView from packaging.version import Version from .conftest import APISPEC_VERSION from .schemas import Foo from .schemas import Query from apiflask import Schema from apiflask.fields imp...
200
assert
numeric_literal
tests/test_decorator_output.py
test_output
40
null
apiflask/apiflask
import os import sys from importlib import metadata, reload import re import pytest from packaging.version import Version full_examples = [ 'basic', 'orm', 'cbv', 'openapi/basic', 'blueprint_tags', 'base_response/marshmallow', 'base_response/pydantic', 'pydantic', 'dataclass', ] e...
404
assert
numeric_literal
examples/test_examples.py
test_get_pet
74
null
apiflask/apiflask
import pytest from marshmallow import fields from marshmallow import Schema from marshmallow import ValidationError from apiflask.schema_adapters import registry from apiflask.schema_adapters.marshmallow import MarshmallowAdapter class TestFlaskParser: def test_location_loader_form_and_files(self): """Te...
'test'
assert
string_literal
tests/test_schema_adapters.py
test_location_loader_form_and_files
TestFlaskParser
337
null
apiflask/apiflask
from marshmallow import fields from marshmallow import Schema from marshmallow import validate from apiflask.openapi_adapters import get_unique_schema_name from apiflask.openapi_adapters import OpenAPIHelper class TestOpenAPIHelper: def test_schema_to_parameters_unknown_type(self): """Test schema_to_para...
[]
assert
collection
tests/test_openapi_adapters.py
test_schema_to_parameters_unknown_type
TestOpenAPIHelper
212
null
fgmacedo/python-statemachine
import logging import xml.etree.ElementTree as ET from unittest.mock import Mock import pytest from statemachine.io.scxml.actions import EventDataWrapper from statemachine.io.scxml.actions import Log from statemachine.io.scxml.actions import ParseTime from statemachine.io.scxml.actions import create_action_callable fr...
"x > 0"
assert
string_literal
tests/test_scxml_units.py
test_str_with_cond
TestIfBranch
165
null
fgmacedo/python-statemachine
import pytest from statemachine.callbacks import CallbackGroup from statemachine.callbacks import CallbackSpec from statemachine.dispatcher import Listener from statemachine.dispatcher import Listeners from statemachine.dispatcher import resolver_factory_from_objects from statemachine.exceptions import InvalidDefinitio...
"Frodo"
assert
string_literal
tests/test_dispatcher.py
test_retrieve_a_callable_from_a_property_name
TestEnsureCallable
88
null
fgmacedo/python-statemachine
import pytest from statemachine.event import Event from statemachine.exceptions import InvalidDefinition from statemachine import State from statemachine import StateChart class TestExplicitEvent: def test_of_passing_event_as_parameters(self): class TrafficLightMachine(StateChart): "A traffic...
"Loop"
assert
string_literal
tests/test_events.py
test_of_passing_event_as_parameters
TestExplicitEvent
139
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart from statemachine import exceptions def test_transition_should_choose_final_state_on_multiple_possibilities( approval_machine, current_time ): # given model = Request() machine = approval_machine(model) model._is_ok ...
model
assert
variable
tests/test_multiple_destinations.py
test_transition_should_choose_final_state_on_multiple_possibilities
27
null
fgmacedo/python-statemachine
import warnings import pytest from statemachine import State from statemachine import StateMachine from statemachine import exceptions class TestSelfTransitionNoEntries: def test_internal_self_transition_does_not_fire_enter_exit(self): log = [] class SM(StateMachine): s1 = State(ini...
log
assert
variable
tests/test_statemachine_compat.py
test_internal_self_transition_does_not_fire_enter_exit
TestSelfTransitionNoEntries
303
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import Event from statemachine import State from statemachine import StateChart class TestErrorHandlerBehaviorLOTR: def test_on_callback_receives_error_kwarg(self): """The `on` callback receives the original error via `...
{sm.lost}
assert
collection
tests/test_error_execution.py
test_on_callback_receives_error_kwarg
TestErrorHandlerBehaviorLOTR
702
null
fgmacedo/python-statemachine
import pytest from statemachine.orderedset import OrderedSet from statemachine import HistoryState from statemachine import State from statemachine import StateChart from statemachine import exceptions from tests.models import MyModel def test_defined_value_must_be_assigned_to_models(campaign_machine_with_values): ...
2
assert
numeric_literal
tests/test_statemachine.py
test_defined_value_must_be_assigned_to_models
250
null
fgmacedo/python-statemachine
import logging import xml.etree.ElementTree as ET from unittest.mock import Mock import pytest from statemachine.io.scxml.actions import EventDataWrapper from statemachine.io.scxml.actions import Log from statemachine.io.scxml.actions import ParseTime from statemachine.io.scxml.actions import create_action_callable fr...
"ev")
assert_*
string_literal
tests/test_scxml_units.py
test_send_to_parent_param_without_expr_skipped
TestSendToParentParams
718
null
fgmacedo/python-statemachine
import logging import xml.etree.ElementTree as ET from unittest.mock import Mock import pytest from statemachine.io.scxml.actions import EventDataWrapper from statemachine.io.scxml.actions import Log from statemachine.io.scxml.actions import ParseTime from statemachine.io.scxml.actions import create_action_callable fr...
"result"
assert
string_literal
tests/test_scxml_units.py
test_run_with_instance_not_class
TestInvokeCallableWrapperRunInstance
1,030
null
fgmacedo/python-statemachine
import warnings import pytest from statemachine import State from statemachine import StateMachine from statemachine import exceptions class TestErrorOnExecutionFalse: def test_runtime_error_in_action_propagates(self): class SM(StateMachine): s1 = State(initial=True) s2 = State(f...
RuntimeError, match="boom")
pytest.raises
complex_expr
tests/test_statemachine_compat.py
test_runtime_error_in_action_propagates
TestErrorOnExecutionFalse
240
null
fgmacedo/python-statemachine
from unittest import mock import pytest from statemachine.callbacks import CallbackGroup from statemachine.callbacks import CallbacksExecutor from statemachine.callbacks import CallbackSpec from statemachine.callbacks import CallbackSpecList from statemachine.callbacks import CallbacksRegistry from statemachine.dispat...
"HOBBIT"
assert
string_literal
tests/test_callbacks.py
test_decorate_unbounded_function
TestCallbacksAsDecorator
167
null
fgmacedo/python-statemachine
from statemachine import State from statemachine import StateChart def sync_main(): sm = AsyncStateMachine() result = sm.start() print(f"Start result is {result}") result = sm.send("finish") print(f"Finish result is {result}") print(list(sm.configuration)) assert sm.final in
sm.configuration
assert
complex_expr
tests/examples/async_without_loop_machine.py
sync_main
41
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestInCondition: async def test_in_condition_false_blocks_transition(self, sm_runner): """In('state_id') when state is not active -> transition blocked.""" class GateOfMoria(StateChart): outside = ...
sm.configuration_values
assert
complex_expr
tests/test_statechart_in_condition.py
test_in_condition_false_blocks_transition
TestInCondition
57
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart def _state_by_name(sm, name): return getattr(sm, name) @pytest.mark.timeout(5) @pytest.mark.parametrize( ("character", "peril", "expected"), [ # --- Gandalf: magic + ring resistance + combat + endurance --- p...
{_state_by_name(sm, expected)}
assert
collection
tests/test_fellowship_quest.py
test_single_peril_outcome
311
null