docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
# For .egg, zipimporter does not have get_filename until Python 2.7.
if hasattr(loader, 'get_filename'):
filepath = loader.get_filename(import_name)
else:
# Fall back to imports.
__import__(import_name)
filepath = sys.modules[import_name].__file__
# filepath is import_nam... | <mask> """
<mask> loader = pkgutil.get_loader(import_name)
<mask> if loader is None:
<mask> return os.getcwd()
<mask> filepath = os.path.abspath(loader.get_filename(import_name))
<mask> # filepath for import_name.py for a module, or __init__.py for a package.
<mask> return os.path... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f | flask/helpers.py |
if loader is None or import_name == '__main__':
# import name is not found, or interactive/main module
package_path = os.getcwd()
else:
# For .egg, zipimporter does not have get_filename until Python 2.7.
if hasattr(loader, 'get_filename'):
filename = loader.get_filen... | <mask> folder structure exists (lib, share etc.).
<mask> """
<mask> root_mod_name = import_name.split('.')[0]
<mask> loader = pkgutil.get_loader(root_mod_name)
<mask> if loader is not None:
<mask> filename = loader.get_filename(root_mod_name)
<mask> package_path = os.path.absp... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f | flask/helpers.py |
<mask> package_path = os.path.abspath(os.path.dirname(filename))
<mask> # package_path ends with __init__.py for a package
<mask> if loader.is_package(root_mod_name):
<mask> package_path = os.path.dirname(package_path)
<mask> else:
<mask> # support for the interacti... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f | flask/helpers.py | |
site_parent, site_folder = os.path.split(package_path) | <mask> test_package_path = package_path
<mask> if os.path.basename(test_package_path).endswith('.egg'):
<mask> test_package_path = os.path.dirname(test_package_path)
<mask>
<mask> site_parent, site_folder = os.path.split(test_package_path)
<mask> py_prefix = os.path.abspath(sys.prefix)
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f | flask/helpers.py |
if package_path.startswith(py_prefix): | <mask> test_package_path = os.path.dirname(test_package_path)
<mask>
<mask> site_parent, site_folder = os.path.split(test_package_path)
<mask> py_prefix = os.path.abspath(sys.prefix)
<mask> if test_package_path.startswith(py_prefix):
<mask> return py_prefix, package_path
<mask> e... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f | flask/helpers.py |
get_flashed_messages, get_template_attribute, json | <mask>
<mask> from flask.app import Flask, Request, Response
<mask> from flask.config import Config
<mask> from flask.helpers import url_for, jsonify, json_available, flash, send_file, \
<mask> get_flashed_messages, render_template, render_template, render_template_string, \
<mask> get_template_attribute... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3c9494f67a0e89d44f459dac9eb9d0bc9b9025b | flask/__init__.py |
from jinja2 import Environment
| <mask> from threading import Lock
<mask> from datetime import timedelta, datetime
<mask> from itertools import chain
<mask>
<mask> from jinja2 import Environment, BaseLoader, FileSystemLoader, TemplateNotFound
<mask> from werkzeug import ImmutableDict, create_environ
<mask> from werkzeug.routing import Map, Rul... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3c9494f67a0e89d44f459dac9eb9d0bc9b9025b | flask/app.py |
from flask.templating import _DispatchingJinjaLoader | <mask> from flask.session import Session, _NullSession
<mask> from flask.module import _ModuleSetupState
<mask>
<mask> # a lock used for logger initialization
<mask> _logger_lock = Lock()
<mask>
<mask>
<mask> class Flask(_PackageBoundObject):
</s> Moved templating stuff into a separate module </s> remove cl... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3c9494f67a0e89d44f459dac9eb9d0bc9b9025b | flask/app.py |
<mask> # a lock used for logger initialization
<mask> _logger_lock = Lock()
<mask>
<mask>
<mask> class _DispatchingJinjaLoader(BaseLoader):
<mask> """A loader that looks for templates in the application and all
<mask> the module folders.
<mask> """
<mask>
<mask> def __init__(self, app):
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/a3c9494f67a0e89d44f459dac9eb9d0bc9b9025b | flask/app.py | |
<mask> rv.headers.pop('x-sendfile', None)
<mask> return rv
<mask>
<mask>
<mask> def render_template(template_name, **context):
<mask> """Renders a template from the template folder with the given
<mask> context.
<mask>
<mask> :param template_name: the name of the template to ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/pallets/flask/commit/a3c9494f67a0e89d44f459dac9eb9d0bc9b9025b | flask/helpers.py | |
`false`, the default behavior will not kick in (in this case, navigate | <mask> browser is done loading the basic parts of the page.
<mask> 2. ``$('selector')`` selects an element and lets you operate on it.
<mask> 3. ``element.bind('event', func)`` specifies a function that should run
<mask> when the user clicked on the element. If that function returns
<mask> `false`, the d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3cb2a33829ee517530d30cd920e5d652b358086 | docs/patterns/jquery.rst |
added. The default behavior is now to attach etags. | <mask> .. versionadded:: 0.2
<mask>
<mask> .. versionadded:: 0.5
<mask> The `add_etags`, `cache_timeout` and `conditional` parameters were
<mask> added. The default behaviour is now to attach etags.
<mask>
<mask> .. versionchanged:: 0.7
<mask> mimetype guessing and etag suppo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3cb2a33829ee517530d30cd920e5d652b358086 | flask/helpers.py |
# XXX: this behavior is now deprecated because it was unreliable. | <mask> from warnings import warn
<mask> file = filename_or_fp
<mask> filename = getattr(file, 'name', None)
<mask>
<mask> # XXX: this behaviour is now deprecated because it was unreliable.
<mask> # removed in Flask 1.0
<mask> if not attachment_filename and not mim... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3cb2a33829ee517530d30cd920e5d652b358086 | flask/helpers.py |
'function because this behavior was unreliable. Pass ' | <mask> stacklevel=2)
<mask> if add_etags:
<mask> warn(DeprecationWarning('In future flask releases etags will no '
<mask> 'longer be generated for file objects passed to the send_file '
<mask> 'function because this behaviour was unreliable. Pass... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a3cb2a33829ee517530d30cd920e5d652b358086 | flask/helpers.py |
- Fix registering a blueprint twice with differing names. :issue:`4124` | <mask> - Support View and MethodView instances with async handlers. :issue:`4112`
<mask> - Enhance typing of ``app.errorhandler`` decorator. :issue:`4095`
<mask>
<mask>
<mask> Version 2.0.1
<mask> -------------
</s> Fix registering a blueprint twice with differing names
Previously the blueprint recorded a... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | CHANGES.rst |
<mask> .. versionchanged:: 2.0.1
<mask> Registering the same blueprint with the same name multiple
<mask> times is deprecated and will become an error in Flask 2.1.
<mask> """
<mask> first_registration = not any(bp is self for bp in app.blueprints.values())
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | src/flask/blueprints.py | |
first_bp_registration = not any(bp is self for bp in app.blueprints.values())
first_name_registration = name not in app.blueprints
| <mask> )
<mask>
<mask> app.blueprints[name] = self
<mask> self._got_registered_once = True
<mask> state = self.make_setup_state(app, options, first_bp_registration)
<mask>
</s> Fix registering a blueprint twice with differing names
Previously the blueprint recorded aspe... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | src/flask/blueprints.py |
state = self.make_setup_state(app, options, first_bp_registration) | <mask> )
<mask>
<mask> app.blueprints[name] = self
<mask> self._got_registered_once = True
<mask> state = self.make_setup_state(app, options, first_registration)
<mask>
<mask> if self.has_static_folder:
<mask> state.add_url_rule(
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | src/flask/blueprints.py |
if first_bp_registration or first_name_registration: | <mask> endpoint="static",
<mask> )
<mask>
<mask> # Merge blueprint data into parent.
<mask> if first_registration:
<mask>
<mask> def extend(bp_dict, parent_dict):
<mask> for key, values in bp_dict.items():
<mask> key ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | src/flask/blueprints.py |
@bp.get("/error")
def error():
flask.abort(403)
@bp.errorhandler(403)
def forbidden(_: Exception):
return "Error", 403
| <mask> def index():
<mask> return flask.request.endpoint
<mask>
<mask> @bp2.get("/")
<mask> def index2():
<mask> return flask.request.endpoint
<mask>
<mask> bp.register_blueprint(bp2, url_prefix="/a", name="sub")
</s> Fix registering a blueprint twice with differing names
Pre... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | tests/test_blueprints.py |
assert client.get("/a/error").data == b"Error"
assert client.get("/b/error").data == b"Error" | <mask> assert client.get("/a/").data == b"bp.index"
<mask> assert client.get("/b/").data == b"alt.index"
<mask> assert client.get("/a/a/").data == b"bp.sub.index2"
<mask> assert client.get("/b/a/").data == b"alt.sub.index2"
</s> Fix registering a blueprint twice with differing names
Previously the... | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/a44c7228600044f530856a33c7da147c528644ff | tests/test_blueprints.py |
pip install -r test-requirements.txt
tox -e py-release | <mask>
<mask> all: clean-pyc test
<mask>
<mask> test:
<mask> pip install -r test-requirements.txt -q
<mask> FLASK_DEBUG= py.test tests examples
<mask>
<mask> tox-test:
<mask> tox
<mask>
<mask> audit:
<mask> python setup.py audit
<mask>
<mask> release:
</s> Use tox from make test </s> remove ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4ed3d28066bb1625c15fc6a89c1533535dc7879 | Makefile |
norecursedirs = .* *.egg *.egg-info env* artwork docs | <mask> [metadata]
<mask> license_file = LICENSE
<mask>
<mask> [tool:pytest]
<mask> norecursedirs = .* *.egg *.egg-info env* artwork docs examples
</s> Use tox from make test </s> remove py.test [] --cov=flask --cov-report html
</s> add # We need to install those after Flask is installed.
pip install... | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/a4ed3d28066bb1625c15fc6a89c1533535dc7879 | setup.cfg |
passenv = LANG | <mask>
<mask>
<mask> [testenv]
<mask> usedevelop=true
<mask> commands =
<mask> # We need to install those after Flask is installed.
<mask> pip install -e examples/flaskr
</s> Use tox from make test </s> remove py.test [] --cov=flask --cov-report html
</s> add # We need to install those after ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4ed3d28066bb1625c15fc6a89c1533535dc7879 | tox.ini |
# We need to install those after Flask is installed.
pip install -e examples/flaskr
pip install -e examples/minitwit
py.test --cov=flask --cov-report html [] | <mask>
<mask> [testenv]
<mask> usedevelop=true
<mask> commands =
<mask> py.test [] --cov=flask --cov-report html
<mask> deps=
<mask> pytest
<mask> pytest-cov
<mask> greenlet
<mask>
</s> Use tox from make test </s> remove norecursedirs = .* *.egg *.egg-info env* artwork docs examples
</s> a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4ed3d28066bb1625c15fc6a89c1533535dc7879 | tox.ini |
- Passing the ``json`` argument to ``app.test_client`` does not
push/pop an extra app context. (`#2900`_) | <mask> routing. This fixes the unexpected behavior that had been introduced
<mask> in 1.0. (`#2986`_)
<mask>
<mask> .. _#2766: https://github.com/pallets/flask/issues/2766
<mask> .. _#2765: https://github.com/pallets/flask/pull/2765
<mask> .. _#2825: https://github.com/pallets/flask/pull/2825
</s> don't... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | CHANGES.rst |
.. _#2900: https://github.com/pallets/flask/issues/2900 | <mask>
<mask> .. _#2766: https://github.com/pallets/flask/issues/2766
<mask> .. _#2765: https://github.com/pallets/flask/pull/2765
<mask> .. _#2825: https://github.com/pallets/flask/pull/2825
<mask> .. _#2933: https://github.com/pallets/flask/issues/2933
<mask> .. _#2986: https://github.com/pallets/flask/pull/29... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | CHANGES.rst |
def _dump_arg_defaults(kwargs, app=None): | <mask> functions of this module but also :attr:`~flask.Request`.
<mask> """
<mask>
<mask>
<mask> def _dump_arg_defaults(kwargs):
<mask> """Inject default arguments for dump functions."""
<mask> if current_app:
<mask> bp = current_app.blueprints.get(request.blueprint) if request else No... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
if app is None:
app = current_app
if app:
bp = app.blueprints.get(request.blueprint) if request else None | <mask>
<mask>
<mask> def _dump_arg_defaults(kwargs):
<mask> """Inject default arguments for dump functions."""
<mask> if current_app:
<mask> bp = current_app.blueprints.get(request.blueprint) if request else None
<mask> kwargs.setdefault(
<mask> 'cls',
<mask> b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
'cls', bp.json_encoder if bp and bp.json_encoder else app.json_encoder | <mask> """Inject default arguments for dump functions."""
<mask> if current_app:
<mask> bp = current_app.blueprints.get(request.blueprint) if request else None
<mask> kwargs.setdefault(
<mask> 'cls',
<mask> bp.json_encoder if bp and bp.json_encoder
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
if not app.config['JSON_AS_ASCII']: | <mask> bp.json_encoder if bp and bp.json_encoder
<mask> else current_app.json_encoder
<mask> )
<mask>
<mask> if not current_app.config['JSON_AS_ASCII']:
<mask> kwargs.setdefault('ensure_ascii', False)
<mask>
<mask> kwargs.setdefault('sort_keys', ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
kwargs.setdefault('sort_keys', app.config['JSON_SORT_KEYS']) | <mask>
<mask> if not current_app.config['JSON_AS_ASCII']:
<mask> kwargs.setdefault('ensure_ascii', False)
<mask>
<mask> kwargs.setdefault('sort_keys', current_app.config['JSON_SORT_KEYS'])
<mask> else:
<mask> kwargs.setdefault('sort_keys', True)
<mask> kwargs.se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
def _load_arg_defaults(kwargs, app=None): | <mask> kwargs.setdefault('sort_keys', True)
<mask> kwargs.setdefault('cls', JSONEncoder)
<mask>
<mask>
<mask> def _load_arg_defaults(kwargs):
<mask> """Inject default arguments for load functions."""
<mask> if current_app:
<mask> bp = current_app.blueprints.get(request.blueprin... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
if app is None:
app = current_app
if app:
bp = app.blueprints.get(request.blueprint) if request else None | <mask>
<mask>
<mask> def _load_arg_defaults(kwargs):
<mask> """Inject default arguments for load functions."""
<mask> if current_app:
<mask> bp = current_app.blueprints.get(request.blueprint) if request else None
<mask> kwargs.setdefault(
<mask> 'cls',
<mask> b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
else app.json_decoder | <mask> bp = current_app.blueprints.get(request.blueprint) if request else None
<mask> kwargs.setdefault(
<mask> 'cls',
<mask> bp.json_decoder if bp and bp.json_decoder
<mask> else current_app.json_decoder
<mask> )
<mask> else:
<mask> kw... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
def dumps(obj, app=None, **kwargs):
"""Serialize ``obj`` to a JSON-formatted string. If there is an
app context pushed, use the current app's configured encoder
(:attr:`~flask.Flask.json_encoder`), or fall back to the default
:class:`JSONEncoder`.
Takes the same arguments as the built-in :func:`jso... | <mask>
<mask> return 'utf-8'
<mask>
<mask>
<mask> def dumps(obj, **kwargs):
<mask> """Serialize ``obj`` to a JSON formatted ``str`` by using the application's
<mask> configured encoder (:attr:`~flask.Flask.json_encoder`) if there is an
<mask> application on the stack.
<mask>
<mask> Thi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
``app`` can be passed directly, rather than requiring an app
context for configuration. | <mask> """Serialize ``obj`` to a JSON formatted ``str`` by using the application's
<mask> configured encoder (:attr:`~flask.Flask.json_encoder`) if there is an
<mask> application on the stack.
<mask>
<mask> This function can return ``unicode`` strings or ascii-only bytestrings by
<mask> defau... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
_dump_arg_defaults(kwargs, app=app) | <mask> default which coerce into unicode strings automatically. That behavior by
<mask> default is controlled by the ``JSON_AS_ASCII`` configuration variable
<mask> and can be overridden by the simplejson ``ensure_ascii`` parameter.
<mask> """
<mask> _dump_arg_defaults(kwargs)
<mask> enco... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
def dump(obj, fp, app=None, **kwargs): | <mask> rv = rv.encode(encoding)
<mask> return rv
<mask>
<mask>
<mask> def dump(obj, fp, **kwargs):
<mask> """Like :func:`dumps` but writes into a file object."""
<mask> _dump_arg_defaults(kwargs)
<mask> encoding = kwargs.pop('encoding', None)
<mask> if encoding is not None:
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
_dump_arg_defaults(kwargs, app=app) | <mask>
<mask>
<mask> def dump(obj, fp, **kwargs):
<mask> """Like :func:`dumps` but writes into a file object."""
<mask> _dump_arg_defaults(kwargs)
<mask> encoding = kwargs.pop('encoding', None)
<mask> if encoding is not None:
<mask> fp = _wrap_writer_for_text(fp, encoding)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
def loads(s, app=None, **kwargs):
"""Deserialize an object from a JSON-formatted string ``s``. If
there is an app context pushed, use the current app's configured
decoder (:attr:`~flask.Flask.json_decoder`), or fall back to the
default :class:`JSONDecoder`.
Takes the same arguments as the built-in ... | <mask> fp = _wrap_writer_for_text(fp, encoding)
<mask> _json.dump(obj, fp, **kwargs)
<mask>
<mask>
<mask> def loads(s, **kwargs):
<mask> """Unserialize a JSON object from a string ``s`` by using the application's
<mask> configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
_load_arg_defaults(kwargs, app=app) | <mask> """Unserialize a JSON object from a string ``s`` by using the application's
<mask> configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
<mask> application on the stack.
<mask> """
<mask> _load_arg_defaults(kwargs)
<mask> if isinstance(s, bytes):
<mask> enco... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
def load(fp, app=None, **kwargs):
"""Like :func:`loads` but reads from a file object."""
_load_arg_defaults(kwargs, app=app) | <mask> s = s.decode(encoding)
<mask> return _json.loads(s, **kwargs)
<mask>
<mask>
<mask> def load(fp, **kwargs):
<mask> """Like :func:`loads` but reads from a file object.
<mask> """
<mask> _load_arg_defaults(kwargs)
<mask> if not PY2:
<mask> fp = _wrap_reader_for_text(f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/json/__init__.py |
# TODO use EnvironBuilder.json_dumps once we require Werkzeug 0.15 | <mask> path += sep + url.query
<mask>
<mask> if 'json' in kwargs:
<mask> assert 'data' not in kwargs, "Client cannot provide both 'json' and 'data'."
<mask> kwargs['data'] = json_dumps(kwargs.pop('json'), app=app)
<mask>
</s> don't push app context for test client json </s> remo... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/testing.py |
assert 'data' not in kwargs, "Client cannot provide both 'json' and 'data'."
kwargs['data'] = json_dumps(kwargs.pop('json'), app=app) | <mask> sep = b'?' if isinstance(url.query, bytes) else '?'
<mask> path += sep + url.query
<mask>
<mask> if 'json' in kwargs:
<mask> assert 'data' not in kwargs, (
<mask> "Client cannot provide both 'json' and 'data'."
<mask> )
<mask>
<mask> # pu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | flask/testing.py |
from flask import appcontext_popped | <mask> import werkzeug
<mask>
<mask> from flask._compat import text_type
<mask> from flask.cli import ScriptInfo
<mask> from flask.json import jsonify
<mask> from flask.testing import make_test_environ_builder, FlaskCliRunner
</s> don't push app context for test client json </s> remove def load(fp, **kwargs):
... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | tests/test_testing.py |
try:
import blinker
except ImportError:
blinker = None
| <mask> from flask.testing import make_test_environ_builder, FlaskCliRunner
<mask>
<mask>
<mask> def test_environ_defaults_from_config(app, client):
<mask> app.config['SERVER_NAME'] = 'example.com:1234'
<mask> app.config['APPLICATION_ROOT'] = '/foo'
<mask>
<mask> @app.route('/')
</s> don't push a... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a4f0f197962b27a002c45f5e27b13a8d4a27ee63 | tests/test_testing.py |
<mask> Flask and all of its dependencies support Python 3 so you can in theory
<mask> start working on it already. There are however a few things you should be
<mask> aware of before you start using Python 3 for your next project.
<mask>
<mask> Requirements
<mask> ------------
<mask>
<mask> If you want to us... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5d24ac0d96a4e464d37c86267b4813c2f236ee8 | docs/python3.rst | |
`itsdangerous`, `Jinja2` and `Werkzeug`. Flask 0.10 and Werkzeug 0.9 were
the first versions to introduce Python 3 support. | <mask> If you want to use Flask with Python 3 you will need to use Python 3.3 or
<mask> higher. 3.2 and older are *not* supported.
<mask>
<mask> In addition to that you need to use the latest and greatest versions of
<mask> `itsdangerous`, `Jinja2` and `Werkzeug`.
<mask>
<mask> API Stability
<mask> ---------... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5d24ac0d96a4e464d37c86267b4813c2f236ee8 | docs/python3.rst |
<mask> middlewares and interacting with the WSGI provided information. Werkzeug
<mask> wraps all that information in high-level helpers but some of those were
<mask> specifically added for the Python 3 support and are quite new.
<mask>
<mask> A lot of the documentation out there on using WSGI leaves out those
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5d24ac0d96a4e464d37c86267b4813c2f236ee8 | docs/python3.rst | |
- Implemented :meth:`~flask.testing.TestClient.session_transaction` to
easily modify sessions from the test environment. | <mask> the perfect place to put configuration files etc. For more information
<mask> see :ref:`instance-folders`.
<mask> - Added the ``APPLICATION_ROOT`` configuration variable.
<mask>
<mask> Version 0.7.3
<mask> -------------
<mask>
<mask> Bugfix release, release date to be decided
</s> Implemented fla... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | CHANGES |
Test Client
-----------
.. currentmodule:: flask.testing
.. autoclass:: TestClient
:members:
| <mask> .. autoclass:: SessionMixin
<mask> :members:
<mask>
<mask>
<mask> Application Globals
<mask> -------------------
<mask>
<mask> .. currentmodule:: flask
<mask>
</s> Implemented flask.testing.TestClient.session_transaction for quick session modifications in test environments. </s> remove """Wo... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | docs/api.rst |
See :class:`~flask.testing.TestClient` for more information.
| <mask> with app.test_client() as c:
<mask> rv = c.get('/?vodka=42')
<mask> assert request.args['vodka'] == '42'
<mask>
<mask> .. versionchanged:: 0.4
<mask> added support for `with` block usage for the client.
<mask>
<mask> .. versionadded... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | flask/app.py |
from contextlib import contextmanager | <mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask>
<mask> from werkzeug.test import Client, EnvironBuilder
<mask> from flask import _request_ctx_stack
<mask>
<mask>
</s> Implemented flask.testing.TestClient.session_transaction for quick session modifications in test environments. </s> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | flask/testing.py |
"""Works like a regular Werkzeug test client but has some knowledge about
how Flask works to defer the cleanup of the request context stack to the
end of a with body when used in a with statement. For general information
about how to use this class refer to :class:`werkzeug.test.Client`.
Basic usa... | <mask> from flask import _request_ctx_stack
<mask>
<mask>
<mask> class FlaskClient(Client):
<mask> """Works like a regular Werkzeug test client but has some
<mask> knowledge about how Flask works to defer the cleanup of the
<mask> request context stack to the end of a with body when used
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | flask/testing.py |
suite.addTest(unittest.makeSuite(TestToolsTestCase)) | <mask> suite.addTest(unittest.makeSuite(ViewTestCase))
<mask> suite.addTest(unittest.makeSuite(DeprecationsTestCase))
<mask> suite.addTest(unittest.makeSuite(InstanceTestCase))
<mask> if flask.json_available:
<mask> suite.addTest(unittest.makeSuite(JSONTestCase))
<mask> if flask.signal... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5da2c98f3ed2f9fe254e3b61799b06fa230a175 | tests/flask_tests.py |
- Fixes for PEP451 import loaders and pytest 5.x. :issue:`3275` | <mask> - ``send_file`` url quotes the ":" and "/" characters for more
<mask> compatible UTF-8 filename support in some browsers. :issue:`3074`
<mask>
<mask>
<mask> Version 1.0.3
<mask> -------------
</s> Fixes for PEP451 import loaders and pytest 5.x
- pytest 5.x drops python2 compatibility and therefor... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | CHANGES.rst |
assert 'closed' in str(e.value) | <mask>
<mask> with pytest.raises(sqlite3.ProgrammingError) as e:
<mask> db.execute('SELECT 1')
<mask>
<mask> assert 'closed' in str(e)
<mask>
<mask> The ``init-db`` command should call the ``init_db`` function and output
<mask> a message.
<mask>
<mask> .. code-block:: python
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | docs/tutorial/tests.rst |
assert 'closed' in str(e.value) | <mask>
<mask> with pytest.raises(sqlite3.ProgrammingError) as e:
<mask> db.execute('SELECT 1')
<mask>
<mask> assert 'closed' in str(e)
<mask>
<mask>
<mask> def test_init_db_command(runner, monkeypatch):
<mask> class Recorder(object):
<mask> called = False
</s> Fixes for PEP451... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | examples/tutorial/tests/test_db.py |
def _find_package_path(root_mod_name):
"""Find the path where the module's root exists in"""
if sys.version_info >= (3, 4):
import importlib.util
try:
spec = importlib.util.find_spec(root_mod_name)
if spec is None:
raise ValueError("not found")
# ... | <mask> 'you encounter this error please file a bug against Flask.') %
<mask> loader.__class__.__name__)
<mask>
<mask>
<mask> def find_package(import_name):
<mask> """Finds a package and returns the prefix (or None if the package is
<mask> not installed) as well as the folder that conta... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
if loader is None or root_mod_name == '__main__': | <mask> folder structure exists (lib, share etc.).
<mask> """
<mask> root_mod_name = import_name.split('.')[0]
<mask> loader = pkgutil.get_loader(root_mod_name)
<mask> if loader is None or import_name == '__main__':
<mask> # import name is not found, or interactive/main module
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
return os.getcwd() | <mask> root_mod_name = import_name.split('.')[0]
<mask> loader = pkgutil.get_loader(root_mod_name)
<mask> if loader is None or import_name == '__main__':
<mask> # import name is not found, or interactive/main module
<mask> package_path = os.getcwd()
<mask> else:
<mask> # F... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
__import__(root_mod_name)
filename = sys.modules[root_mod_name].__file__ | <mask> # At least one loader is missing both get_filename and archive:
<mask> # Google App Engine's HardenedModulesHook
<mask> #
<mask> # Fall back to imports.
<mask> __import__(import_name)
<mask> filename = sys.modules[import_name].__file__... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
if _matching_loader_thinks_module_is_package(loader, root_mod_name): | <mask>
<mask> # In case the root module is a package we need to chop of the
<mask> # rightmost part. This needs to go through a helper function
<mask> # because of python 3.3 namespace packages.
<mask> if _matching_loader_thinks_module_is_package(
<mask> loader, r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
return package_path
def find_package(import_name):
"""Finds a package and returns the prefix (or None if the package is
not installed) as well as the folder that contains the package or
module as a tuple. The package path returned is the module that would
have to be added to the pythonpath in ord... | <mask> package_path = os.path.dirname(package_path)
<mask>
<mask> site_parent, site_folder = os.path.split(package_path)
<mask> py_prefix = os.path.abspath(sys.prefix)
<mask> if package_path.startswith(py_prefix):
<mask> return py_prefix, package_path
</s> Fixes for PEP451 import... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | flask/helpers.py |
assert 'returned None' in str(e.value) | <mask> c = app.test_client()
<mask>
<mask> with pytest.raises(TypeError) as e:
<mask> c.get('/none')
<mask> assert 'returned None' in str(e)
<mask>
<mask> with pytest.raises(TypeError) as e:
<mask> c.get('/small_tuple')
<mask> assert 'tuple must have the form' in s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
assert 'tuple must have the form' in str(e.value) | <mask> assert 'returned None' in str(e)
<mask>
<mask> with pytest.raises(TypeError) as e:
<mask> c.get('/small_tuple')
<mask> assert 'tuple must have the form' in str(e)
<mask>
<mask> pytest.raises(TypeError, c.get, '/large_tuple')
<mask>
<mask> with pytest.raises(TypeErr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
assert 'it was a bool' in str(e.value) | <mask> pytest.raises(TypeError, c.get, '/large_tuple')
<mask>
<mask> with pytest.raises(TypeError) as e:
<mask> c.get('/bad_type')
<mask> assert 'it was a bool' in str(e)
<mask>
<mask> pytest.raises(TypeError, c.get, '/bad_wsgi')
<mask>
<mask>
<mask> def test_make_response(app,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
assert 'A setup function was called' in str(e.value) | <mask> with pytest.raises(AssertionError) as e:
<mask> @app.route('/foo')
<mask> def broken():
<mask> return 'Meh'
<mask> assert 'A setup function was called' in str(e)
<mask>
<mask> app.debug = False
<mask>
<mask> @app.route('/foo')
<mask> def working():
</s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
assert 'http://localhost/foo/' in str(e.value) | <mask>
<mask> with client:
<mask> with pytest.raises(AssertionError) as e:
<mask> client.post('/foo', data={})
<mask> assert 'http://localhost/foo/' in str(e)
<mask> assert ('Make sure to directly send '
<mask> 'your POST-request to this URL') in str(e)
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
'your POST-request to this URL') in str(e.value) | <mask> with pytest.raises(AssertionError) as e:
<mask> client.post('/foo', data={})
<mask> assert 'http://localhost/foo/' in str(e)
<mask> assert ('Make sure to directly send '
<mask> 'your POST-request to this URL') in str(e)
<mask>
<mask> rv = client... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_basic.py |
assert 'Unable to infer MIME-type' in str(excinfo.value)
assert 'no filename is available' in str(excinfo.value) | <mask>
<mask> def test_send_file_object_without_mimetype(self, app, req_ctx):
<mask> with pytest.raises(ValueError) as excinfo:
<mask> flask.send_file(StringIO("LOL"))
<mask> assert 'Unable to infer MIME-type' in str(excinfo)
<mask> assert 'no filename is available' in str... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ecdfa7a57bf6bcba7391fc6d356e3f7de33e57 | tests/test_helpers.py |
" WARNING: This is a development server. "
"Do not use it in a production deployment.",
fg="red",
)
click.secho(" Use a production WSGI server instead.", dim=True) | <mask> click.echo(" * Environment: {0}".format(env))
<mask>
<mask> if env == "production":
<mask> click.secho(
<mask> ' WARNING: This is a development server. '
<mask> 'Do not use it in a production deployment.', fg='red')
<mask> click.secho(' Use a production... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | flask/cli.py |
rv = client.get("/dict") | <mask> rv = client.get("/wsgi")
<mask> assert b"Not Found" in rv.data
<mask> assert rv.status_code == 404
<mask>
<mask> rv = client.get('/dict')
<mask> assert rv.json == {"foo": "bar"}
<mask> assert rv.status_code == 201
<mask>
<mask>
<mask> def test_response_type_errors():
</s> Fi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | tests/test_basic.py |
app = flask.Flask(__name__, static_folder="", static_url_path="")
rv = app.test_client().open("/static/index.html", method="GET") | <mask> assert flask.url_for("static", filename="index.html") == "/foo/index.html"
<mask>
<mask>
<mask> def test_static_url_empty_path(app):
<mask> app = flask.Flask(__name__, static_folder='', static_url_path='')
<mask> rv = app.test_client().open('/static/index.html', method='GET')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | tests/test_basic.py |
app = flask.Flask(__name__, static_folder="")
rv = app.test_client().open("/static/index.html", method="GET") | <mask> rv.close()
<mask>
<mask>
<mask> def test_static_url_empty_path_default(app):
<mask> app = flask.Flask(__name__, static_folder='')
<mask> rv = app.test_client().open('/static/index.html', method='GET')
<mask> assert rv.status_code == 200
<mask> rv.close()
<mask>
<mask>
<mask> de... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | tests/test_basic.py |
def test_run_from_config(
monkeypatch, host, port, server_name, expect_host, expect_port, app
): | <mask> (None, None, "localhost:8080", "localhost", 8080),
<mask> (None, None, "localhost:0", "localhost", 0),
<mask> ),
<mask> )
<mask> def test_run_from_config(monkeypatch, host, port, server_name, expect_host, expect_port, app):
<mask> def run_simple_mock(hostname, port, *args, **kwargs)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | tests/test_basic.py |
assert not load_dotenv("non-existent-file") | <mask> # set manually, files don't overwrite
<mask> assert os.environ["EGGS"] == "3"
<mask>
<mask> # Non existent file should not load
<mask> assert not load_dotenv('non-existent-file')
<mask>
<mask>
<mask> @need_dotenv
<mask> def test_dotenv_path(monkeypatch):
<mask> for item in ("FOO"... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a5ff3cd01b8a78b5ed2961a8095290fed4e2a0d5 | tests/test_cli.py |
either upgrade to newer Flask versions or have a look at :doc:`/server`
to see the alternative method for running a server. | <mask>
<mask> Versions of Flask older than 0.11 use to have different ways to start the
<mask> application. In short, the :command:`flask` command did not exist, and
<mask> neither did :command:`python -m flask`. In that case you have two options:
<mask> either upgrade to newer Flask versions or have a look at ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/quickstart.rst |
There are more parameters that are explained in :doc:`/server`. | <mask>
<mask> You can also control debug mode separately from the environment by
<mask> exporting ``FLASK_DEBUG=1``.
<mask>
<mask> There are more parameters that are explained in the :ref:`server` docs.
<mask>
<mask> .. admonition:: Attention
<mask>
<mask> Even though the interactive debugger does not w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/quickstart.rst |
.. currentmodule:: flask | <mask> .. _server:
<mask>
<mask> Development Server
<mask> ==================
<mask>
<mask> .. currentmodule:: flask
</s> rewrite the development server docs </s> remove .. currentmodule:: flask
</s> add Flask provides a ``run`` command to run the application with a
development server. In development mode, th... | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
Flask provides a ``run`` command to run the application with a
development server. In development mode, this server provides an
interactive debugger and will reload when code is changed.
.. warning::
Do not use the development server when deploying to production. It
is intended for use only during local devel... | <mask>
<mask> Development Server
<mask> ==================
<mask>
<mask> .. currentmodule:: flask
<mask>
<mask> Starting with Flask 0.11 there are multiple built-in ways to run a
<mask> development server. The best one is the :command:`flask` command line utility
<mask> but you can also continue using the ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
See :doc:`/deploying/index` for deployment options. | <mask> ==================
<mask>
<mask> .. currentmodule:: flask
<mask>
<mask> Starting with Flask 0.11 there are multiple built-in ways to run a
<mask> development server. The best one is the :command:`flask` command line utility
<mask> but you can also continue using the :meth:`Flask.run` method.
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
The ``flask run`` command line script is the recommended way to run the
development server. It requires setting the ``FLASK_APP`` environment
variable to point to your application, and ``FLASK_ENV=development`` to
fully enable development mode. | <mask>
<mask> Command Line
<mask> ------------
<mask>
<mask> The :command:`flask` command line script (:ref:`cli`) is strongly
<mask> recommended for development because it provides a superior reload
<mask> experience due to how it loads the application. The basic usage is like
<mask> this::
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
.. code-block:: text
$ export FLASK_APP=hello | <mask> recommended for development because it provides a superior reload
<mask> experience due to how it loads the application. The basic usage is like
<mask> this::
<mask>
<mask> $ export FLASK_APP=my_application
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> This enable... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
http://localhost:5000/. Use ``flask run --help`` to see the available
options, and :doc:`/cli` for detailed instructions about configuring
and using the CLI. | <mask> $ flask run
<mask>
<mask> This enables the development environment, including the interactive
<mask> debugger and reloader, and then starts the server on
<mask> *http://localhost:5000/*.
<mask>
<mask> The individual features of the server can be controlled by passing more
<mask> arguments to the ``... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
Prior to Flask 1.0 the ``FLASK_ENV`` environment variable was not
supported and you needed to enable debug mode by exporting | <mask> $ flask run --no-reload
<mask>
<mask> .. note::
<mask>
<mask> Prior to Flask 1.0 the :envvar:`FLASK_ENV` environment variable was
<mask> not supported and you needed to enable debug mode by exporting
<mask> ``FLASK_DEBUG=1``. This can still be used to control debug mode, but
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
As an alternative to the ``flask run`` command, the development server
can also be started from Python with the :meth:`Flask.run` method. This
method takes arguments similar to the CLI options to control the server.
The main difference from the CLI command is that the server will crash
if there are errors when reloadin... | <mask>
<mask> In Code
<mask> -------
<mask>
<mask> The alternative way to start the application is through the
<mask> :meth:`Flask.run` method. This will immediately launch a local server
<mask> exactly the same way the :command:`flask` script does.
<mask>
<mask> Example::
<mask>
<mask> if __name__ ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
.. code-block:: python | <mask> The alternative way to start the application is through the
<mask> :meth:`Flask.run` method. This will immediately launch a local server
<mask> exactly the same way the :command:`flask` script does.
<mask>
<mask> Example::
<mask>
<mask> if __name__ == '__main__':
<mask> app.run()
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
if __name__ == "__main__":
app.run(debug=True) | <mask> exactly the same way the :command:`flask` script does.
<mask>
<mask> Example::
<mask>
<mask> if __name__ == '__main__':
<mask> app.run()
<mask>
<mask> This works well for the common case but it does not work well for
<mask> development which is why from Flask 0.11 onwards the :command:`fl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
.. code-block:: text | <mask>
<mask> if __name__ == '__main__':
<mask> app.run()
<mask>
<mask> This works well for the common case but it does not work well for
<mask> development which is why from Flask 0.11 onwards the :command:`flask`
<mask> method is recommended. The reason for this is that due to how the reload
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
$ python hello.py | <mask> mechanism works there are some bizarre side-effects (like executing
<mask> certain code twice, sometimes crashing without message or dying when a
<mask> syntax or import error happens).
<mask>
<mask> It is however still a perfectly valid method for invoking a non automatic
<mask> reloading application.
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | docs/server.rst |
"--eager-loading/--lazy-loading", | <mask> help="Enable or disable the debugger. By default the debugger "
<mask> "is active if debug is enabled.",
<mask> )
<mask> @click.option(
<mask> "--eager-loading/--lazy-loader",
<mask> default=None,
<mask> help="Enable or disable eager loading. By default eager "
<mask> "loading is ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a671e47921f6b3f1e6c24f34f23b83ed13fe63b6 | src/flask/cli.py |
For more information consult the `mod_wsgi documentation`_. | <mask>
<mask> Require all granted
<mask>
<mask>
<mask> For more information consult the `mod_wsgi wiki`_.
<mask>
<mask> .. _mod_wsgi: http://code.google.com/p/modwsgi/
<mask> .. _installation instructions: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
<mask> .. _virtual python: https://p... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6a36ec72a1f65514e137b0f21708e8c61dbe4ba | docs/deploying/mod_wsgi.rst |
.. _mod_wsgi: https://github.com/GrahamDumpleton/mod_wsgi
.. _installation instructions: http://modwsgi.readthedocs.io/en/develop/installation.html | <mask>
<mask>
<mask> For more information consult the `mod_wsgi wiki`_.
<mask>
<mask> .. _mod_wsgi: http://code.google.com/p/modwsgi/
<mask> .. _installation instructions: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
<mask> .. _virtual python: https://pypi.python.org/pypi/virtualenv
<mask> ..... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6a36ec72a1f65514e137b0f21708e8c61dbe4ba | docs/deploying/mod_wsgi.rst |
.. _mod_wsgi documentation: http://modwsgi.readthedocs.io/en/develop/index.html | <mask>
<mask> .. _mod_wsgi: http://code.google.com/p/modwsgi/
<mask> .. _installation instructions: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
<mask> .. _virtual python: https://pypi.python.org/pypi/virtualenv
<mask> .. _mod_wsgi wiki: http://code.google.com/p/modwsgi/w/list
<mask>
<mask> Tro... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6a36ec72a1f65514e137b0f21708e8c61dbe4ba | docs/deploying/mod_wsgi.rst |
lifecycle | <mask> config
<mask> signals
<mask> views
<mask> appcontext
<mask> reqcontext
<mask> blueprints
<mask> extensions
<mask> cli
</s> document the lifecycle of a flask application and request </s> remove '/make_report/2017', data={'format': 'short'}):
</s> add "/make_re... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6cd8f212e762b8f70e00f3341b27799c0fb657a | docs/index.rst |
format = request.args.get("format") | <mask> everything that runs in the block will have access to :data:`request`,
<mask> populated with your test data. ::
<mask>
<mask> def generate_report(year):
<mask> format = request.args.get('format')
<mask> ...
<mask>
<mask> with app.test_request_context(
<mask> '/make_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6cd8f212e762b8f70e00f3341b27799c0fb657a | docs/reqcontext.rst |
"/make_report/2017", query_string={"format": "short"}
): | <mask> format = request.args.get('format')
<mask> ...
<mask>
<mask> with app.test_request_context(
<mask> '/make_report/2017', data={'format': 'short'}):
<mask> generate_report()
<mask>
<mask> If you see that error somewhere else in your code not related to
<mask> test... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a6cd8f212e762b8f70e00f3341b27799c0fb657a | docs/reqcontext.rst |
- Roll back a change to the order that URL matching was done. The
URL is again matched after the session is loaded, so the session is
available in custom URL converters. :issue:`4053` | <mask> the endpoint name. :issue:`4041`
<mask> - Combine URL prefixes when nesting blueprints that were created with
<mask> a ``url_prefix`` value. :issue:`4037`
<mask>
<mask>
<mask> Version 2.0.0
<mask> -------------
</s> converters have access to session </s> remove def test_open_session_endpoint_... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/a7b02b3a07ae292ce376df2459eae3ffb4c06d52 | CHANGES.rst |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.