apply pyupgrade
This commit is contained in:
parent
57d628ca74
commit
524fd0bc8c
54 changed files with 169 additions and 230 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.conftest
|
||||
~~~~~~~~~~~~~~
|
||||
|
|
@ -112,7 +111,7 @@ def limit_loader(request, monkeypatch):
|
|||
if not request.param:
|
||||
return
|
||||
|
||||
class LimitedLoader(object):
|
||||
class LimitedLoader:
|
||||
def __init__(self, loader):
|
||||
self.loader = loader
|
||||
|
||||
|
|
@ -172,7 +171,7 @@ def install_egg(modules_tmpdir, monkeypatch):
|
|||
textwrap.dedent(
|
||||
"""
|
||||
from setuptools import setup
|
||||
setup(name='{0}',
|
||||
setup(name='{}',
|
||||
version='1.0',
|
||||
packages=['site_egg'],
|
||||
zip_safe=True)
|
||||
|
|
@ -187,7 +186,7 @@ def install_egg(modules_tmpdir, monkeypatch):
|
|||
subprocess.check_call(
|
||||
[sys.executable, "setup.py", "bdist_egg"], cwd=str(modules_tmpdir)
|
||||
)
|
||||
egg_path, = modules_tmpdir.join("dist/").listdir()
|
||||
(egg_path,) = modules_tmpdir.join("dist/").listdir()
|
||||
monkeypatch.syspath_prepend(str(egg_path))
|
||||
return egg_path
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.appctx
|
||||
~~~~~~~~~~~~
|
||||
|
|
@ -163,7 +162,7 @@ def test_app_ctx_globals_methods(app, app_ctx):
|
|||
|
||||
|
||||
def test_custom_app_ctx_globals_class(app):
|
||||
class CustomRequestGlobals(object):
|
||||
class CustomRequestGlobals:
|
||||
def __init__(self):
|
||||
self.spam = "eggs"
|
||||
|
||||
|
|
@ -190,7 +189,7 @@ def test_context_refcounts(app, client):
|
|||
pass
|
||||
env = flask._request_ctx_stack.top.request.environ
|
||||
assert env["werkzeug.request"] is not None
|
||||
return u""
|
||||
return ""
|
||||
|
||||
res = client.get("/")
|
||||
assert res.status_code == 200
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from flask import Flask
|
||||
|
||||
testapp = Flask("testapp")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from flask import Flask
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from flask import Flask
|
||||
|
||||
raise ImportError()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from flask import Flask
|
||||
|
||||
app1 = Flask("app1")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.basic
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -278,7 +277,7 @@ def test_session_using_server_name_port_and_path(app, client):
|
|||
|
||||
|
||||
def test_session_using_application_root(app, client):
|
||||
class PrefixPathMiddleware(object):
|
||||
class PrefixPathMiddleware:
|
||||
def __init__(self, app, prefix):
|
||||
self.app = app
|
||||
self.prefix = prefix
|
||||
|
|
@ -583,18 +582,18 @@ def test_extended_flashing(app):
|
|||
|
||||
@app.route("/")
|
||||
def index():
|
||||
flask.flash(u"Hello World")
|
||||
flask.flash(u"Hello World", "error")
|
||||
flask.flash(flask.Markup(u"<em>Testing</em>"), "warning")
|
||||
flask.flash("Hello World")
|
||||
flask.flash("Hello World", "error")
|
||||
flask.flash(flask.Markup("<em>Testing</em>"), "warning")
|
||||
return ""
|
||||
|
||||
@app.route("/test/")
|
||||
def test():
|
||||
messages = flask.get_flashed_messages()
|
||||
assert list(messages) == [
|
||||
u"Hello World",
|
||||
u"Hello World",
|
||||
flask.Markup(u"<em>Testing</em>"),
|
||||
"Hello World",
|
||||
"Hello World",
|
||||
flask.Markup("<em>Testing</em>"),
|
||||
]
|
||||
return ""
|
||||
|
||||
|
|
@ -603,9 +602,9 @@ def test_extended_flashing(app):
|
|||
messages = flask.get_flashed_messages(with_categories=True)
|
||||
assert len(messages) == 3
|
||||
assert list(messages) == [
|
||||
("message", u"Hello World"),
|
||||
("error", u"Hello World"),
|
||||
("warning", flask.Markup(u"<em>Testing</em>")),
|
||||
("message", "Hello World"),
|
||||
("error", "Hello World"),
|
||||
("warning", flask.Markup("<em>Testing</em>")),
|
||||
]
|
||||
return ""
|
||||
|
||||
|
|
@ -614,7 +613,7 @@ def test_extended_flashing(app):
|
|||
messages = flask.get_flashed_messages(
|
||||
category_filter=["message"], with_categories=True
|
||||
)
|
||||
assert list(messages) == [("message", u"Hello World")]
|
||||
assert list(messages) == [("message", "Hello World")]
|
||||
return ""
|
||||
|
||||
@app.route("/test_filters/")
|
||||
|
|
@ -623,8 +622,8 @@ def test_extended_flashing(app):
|
|||
category_filter=["message", "warning"], with_categories=True
|
||||
)
|
||||
assert list(messages) == [
|
||||
("message", u"Hello World"),
|
||||
("warning", flask.Markup(u"<em>Testing</em>")),
|
||||
("message", "Hello World"),
|
||||
("warning", flask.Markup("<em>Testing</em>")),
|
||||
]
|
||||
return ""
|
||||
|
||||
|
|
@ -632,8 +631,8 @@ def test_extended_flashing(app):
|
|||
def test_filters2():
|
||||
messages = flask.get_flashed_messages(category_filter=["message", "warning"])
|
||||
assert len(messages) == 2
|
||||
assert messages[0] == u"Hello World"
|
||||
assert messages[1] == flask.Markup(u"<em>Testing</em>")
|
||||
assert messages[0] == "Hello World"
|
||||
assert messages[1] == flask.Markup("<em>Testing</em>")
|
||||
return ""
|
||||
|
||||
# Create new test client on each test to clean flashed messages.
|
||||
|
|
@ -1102,11 +1101,11 @@ def test_enctype_debug_helper(app, client):
|
|||
def test_response_types(app, client):
|
||||
@app.route("/text")
|
||||
def from_text():
|
||||
return u"Hällo Wörld"
|
||||
return "Hällo Wörld"
|
||||
|
||||
@app.route("/bytes")
|
||||
def from_bytes():
|
||||
return u"Hällo Wörld".encode("utf-8")
|
||||
return "Hällo Wörld".encode()
|
||||
|
||||
@app.route("/full_tuple")
|
||||
def from_full_tuple():
|
||||
|
|
@ -1143,8 +1142,8 @@ def test_response_types(app, client):
|
|||
def from_dict():
|
||||
return {"foo": "bar"}, 201
|
||||
|
||||
assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")
|
||||
assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")
|
||||
assert client.get("/text").data == "Hällo Wörld".encode()
|
||||
assert client.get("/bytes").data == "Hällo Wörld".encode()
|
||||
|
||||
rv = client.get("/full_tuple")
|
||||
assert rv.data == b"Meh"
|
||||
|
|
@ -1611,11 +1610,11 @@ def test_inject_blueprint_url_defaults(app):
|
|||
|
||||
|
||||
def test_nonascii_pathinfo(app, client):
|
||||
@app.route(u"/киртест")
|
||||
@app.route("/киртест")
|
||||
def index():
|
||||
return "Hello World!"
|
||||
|
||||
rv = client.get(u"/киртест")
|
||||
rv = client.get("/киртест")
|
||||
assert rv.data == b"Hello World!"
|
||||
|
||||
|
||||
|
|
@ -1875,7 +1874,7 @@ def test_multi_route_rules(app, client):
|
|||
|
||||
|
||||
def test_multi_route_class_views(app, client):
|
||||
class View(object):
|
||||
class View:
|
||||
def __init__(self, app):
|
||||
app.add_url_rule("/", "index", self.index)
|
||||
app.add_url_rule("/<test>/", "index", self.index)
|
||||
|
|
@ -1907,12 +1906,12 @@ def test_run_server_port(monkeypatch, app):
|
|||
|
||||
# Mocks werkzeug.serving.run_simple method
|
||||
def run_simple_mock(hostname, port, application, *args, **kwargs):
|
||||
rv["result"] = "running on %s:%s ..." % (hostname, port)
|
||||
rv["result"] = f"running on {hostname}:{port} ..."
|
||||
|
||||
monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)
|
||||
hostname, port = "localhost", 8000
|
||||
app.run(hostname, port, debug=True)
|
||||
assert rv["result"] == "running on %s:%s ..." % (hostname, port)
|
||||
assert rv["result"] == f"running on {hostname}:{port} ..."
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.blueprints
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_cli
|
||||
~~~~~~~~~~~~~~
|
||||
|
|
@ -8,8 +7,6 @@
|
|||
"""
|
||||
# This file was part of Flask-CLI and was modified under the terms of
|
||||
# its Revised BSD License. Copyright © 2015 CERN.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import ssl
|
||||
import sys
|
||||
|
|
@ -261,7 +258,7 @@ def test_get_version(test_apps, capsys):
|
|||
from werkzeug import __version__ as werkzeug_version
|
||||
from platform import python_version
|
||||
|
||||
class MockCtx(object):
|
||||
class MockCtx:
|
||||
resilient_parsing = False
|
||||
color = None
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_config
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -65,7 +64,7 @@ def test_config_from_mapping():
|
|||
|
||||
|
||||
def test_config_from_class():
|
||||
class Base(object):
|
||||
class Base:
|
||||
TEST_KEY = "foo"
|
||||
|
||||
class Test(Base):
|
||||
|
|
@ -186,8 +185,8 @@ def test_from_pyfile_weird_encoding(tmpdir, encoding):
|
|||
f = tmpdir.join("my_config.py")
|
||||
f.write_binary(
|
||||
textwrap.dedent(
|
||||
u"""
|
||||
# -*- coding: {0} -*-
|
||||
"""
|
||||
# -*- coding: {} -*-
|
||||
TEST_VALUE = "föö"
|
||||
""".format(
|
||||
encoding
|
||||
|
|
@ -197,4 +196,4 @@ def test_from_pyfile_weird_encoding(tmpdir, encoding):
|
|||
app = flask.Flask(__name__)
|
||||
app.config.from_pyfile(str(f))
|
||||
value = app.config["TEST_VALUE"]
|
||||
assert value == u"föö"
|
||||
assert value == "föö"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ def test_custom_converters(app, client):
|
|||
return value.split(",")
|
||||
|
||||
def to_url(self, value):
|
||||
base_to_url = super(ListConverter, self).to_url
|
||||
base_to_url = super().to_url
|
||||
return ",".join(base_to_url(x) for x in value)
|
||||
|
||||
app.url_map.converters["list"] = ListConverter
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.helpers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -38,7 +37,7 @@ def has_encoding(name):
|
|||
return False
|
||||
|
||||
|
||||
class FakePath(object):
|
||||
class FakePath:
|
||||
"""Fake object to represent a ``PathLike object``.
|
||||
|
||||
This represents a ``pathlib.Path`` object in python 3.
|
||||
|
|
@ -73,9 +72,9 @@ class FixedOffset(datetime.tzinfo):
|
|||
return datetime.timedelta()
|
||||
|
||||
|
||||
class TestJSON(object):
|
||||
class TestJSON:
|
||||
@pytest.mark.parametrize(
|
||||
"value", (1, "t", True, False, None, [], [1, 2, 3], {}, {"foo": u"🐍"})
|
||||
"value", (1, "t", True, False, None, [], [1, 2, 3], {}, {"foo": "🐍"})
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"encoding",
|
||||
|
|
@ -126,12 +125,12 @@ class TestJSON(object):
|
|||
assert rv.data == b"foo"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_value,expected", [(True, '"\\u2603"'), (False, u'"\u2603"')]
|
||||
"test_value,expected", [(True, '"\\u2603"'), (False, '"\u2603"')]
|
||||
)
|
||||
def test_json_as_unicode(self, test_value, expected, app, app_ctx):
|
||||
|
||||
app.config["JSON_AS_ASCII"] = test_value
|
||||
rv = flask.json.dumps(u"\N{SNOWMAN}")
|
||||
rv = flask.json.dumps("\N{SNOWMAN}")
|
||||
assert rv == expected
|
||||
|
||||
def test_json_dump_to_file(self, app, app_ctx):
|
||||
|
|
@ -217,7 +216,7 @@ class TestJSON(object):
|
|||
)
|
||||
|
||||
for i, d in enumerate(test_dates):
|
||||
url = "/datetest{0}".format(i)
|
||||
url = f"/datetest{i}"
|
||||
app.add_url_rule(url, str(i), lambda val=d: flask.jsonify(x=val))
|
||||
rv = client.get(url)
|
||||
assert rv.mimetype == "application/json"
|
||||
|
|
@ -262,7 +261,7 @@ class TestJSON(object):
|
|||
def test_template_escaping(self, app, req_ctx):
|
||||
render = flask.render_template_string
|
||||
rv = flask.json.htmlsafe_dumps("</script>")
|
||||
assert rv == u'"\\u003c/script\\u003e"'
|
||||
assert rv == '"\\u003c/script\\u003e"'
|
||||
assert type(rv) is str
|
||||
rv = render('{{ "</script>"|tojson }}')
|
||||
assert rv == '"\\u003c/script\\u003e"'
|
||||
|
|
@ -280,7 +279,7 @@ class TestJSON(object):
|
|||
assert rv == '<a ng-data=\'{"x": ["foo", "bar", "baz\\u0027"]}\'></a>'
|
||||
|
||||
def test_json_customization(self, app, client):
|
||||
class X(object): # noqa: B903, for Python2 compatibility
|
||||
class X: # noqa: B903, for Python2 compatibility
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
|
|
@ -315,7 +314,7 @@ class TestJSON(object):
|
|||
assert rv.data == b'"<42>"'
|
||||
|
||||
def test_blueprint_json_customization(self, app, client):
|
||||
class X(object): # noqa: B903, for Python2 compatibility
|
||||
class X: # noqa: B903, for Python2 compatibility
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
|
|
@ -368,9 +367,9 @@ class TestJSON(object):
|
|||
def index():
|
||||
return flask.request.args["foo"]
|
||||
|
||||
rv = client.get(u"/?foo=정상처리".encode("euc-kr"))
|
||||
rv = client.get("/?foo=정상처리".encode("euc-kr"))
|
||||
assert rv.status_code == 200
|
||||
assert rv.data == u"정상처리".encode("utf-8")
|
||||
assert rv.data == "정상처리".encode()
|
||||
|
||||
def test_json_key_sorting(self, app, client):
|
||||
app.debug = True
|
||||
|
|
@ -443,7 +442,7 @@ class TestJSON(object):
|
|||
assert lines == sorted_by_str
|
||||
|
||||
|
||||
class PyBytesIO(object):
|
||||
class PyBytesIO:
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._io = io.BytesIO(*args, **kwargs)
|
||||
|
||||
|
|
@ -451,7 +450,7 @@ class PyBytesIO(object):
|
|||
return getattr(self._io, name)
|
||||
|
||||
|
||||
class TestSendfile(object):
|
||||
class TestSendfile:
|
||||
def test_send_file_regular(self, app, req_ctx):
|
||||
rv = flask.send_file("static/index.html")
|
||||
assert rv.direct_passthrough
|
||||
|
|
@ -516,7 +515,7 @@ class TestSendfile(object):
|
|||
@pytest.mark.parametrize(
|
||||
"opener",
|
||||
[
|
||||
lambda app: io.StringIO(u"Test"),
|
||||
lambda app: io.StringIO("Test"),
|
||||
lambda app: open(os.path.join(app.static_folder, "index.html")),
|
||||
],
|
||||
)
|
||||
|
|
@ -673,13 +672,13 @@ class TestSendfile(object):
|
|||
(
|
||||
("index.html", "index.html", False),
|
||||
(
|
||||
u"Ñandú/pingüino.txt",
|
||||
"Ñandú/pingüino.txt",
|
||||
'"Nandu/pinguino.txt"',
|
||||
"%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt",
|
||||
),
|
||||
(u"Vögel.txt", "Vogel.txt", "V%C3%B6gel.txt"),
|
||||
("Vögel.txt", "Vogel.txt", "V%C3%B6gel.txt"),
|
||||
# ":/" are not safe in filename* value
|
||||
(u"те:/ст", '":/"', "%D1%82%D0%B5%3A%2F%D1%81%D1%82"),
|
||||
("те:/ст", '":/"', "%D1%82%D0%B5%3A%2F%D1%81%D1%82"),
|
||||
),
|
||||
)
|
||||
def test_attachment_filename_encoding(self, filename, ascii, utf8):
|
||||
|
|
@ -775,7 +774,7 @@ class TestSendfile(object):
|
|||
flask.send_from_directory("static", "bad\x00")
|
||||
|
||||
|
||||
class TestUrlFor(object):
|
||||
class TestUrlFor:
|
||||
def test_url_for_with_anchor(self, app, req_ctx):
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
|
@ -834,7 +833,7 @@ class TestUrlFor(object):
|
|||
assert flask.url_for("myview", _method="POST") == "/myview/create"
|
||||
|
||||
|
||||
class TestNoImports(object):
|
||||
class TestNoImports:
|
||||
"""Test Flasks are created without import.
|
||||
|
||||
Avoiding ``__import__`` helps create Flask instances where there are errors
|
||||
|
|
@ -853,7 +852,7 @@ class TestNoImports(object):
|
|||
AssertionError("Flask(import_name) is importing import_name.")
|
||||
|
||||
|
||||
class TestStreaming(object):
|
||||
class TestStreaming:
|
||||
def test_streaming_with_context(self, app, client):
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
|
@ -884,7 +883,7 @@ class TestStreaming(object):
|
|||
def test_streaming_with_context_and_custom_close(self, app, client):
|
||||
called = []
|
||||
|
||||
class Wrapper(object):
|
||||
class Wrapper:
|
||||
def __init__(self, gen):
|
||||
self._gen = gen
|
||||
|
||||
|
|
@ -927,7 +926,7 @@ class TestStreaming(object):
|
|||
assert rv.data == b"flask"
|
||||
|
||||
|
||||
class TestSafeJoin(object):
|
||||
class TestSafeJoin:
|
||||
def test_safe_join(self):
|
||||
# Valid combinations of *args and expected joined paths.
|
||||
passing = (
|
||||
|
|
@ -968,7 +967,7 @@ class TestSafeJoin(object):
|
|||
print(flask.safe_join(*args))
|
||||
|
||||
|
||||
class TestHelpers(object):
|
||||
class TestHelpers:
|
||||
@pytest.mark.parametrize(
|
||||
"debug, expected_flag, expected_default_flag",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_instance
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_json_tag
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -48,7 +47,7 @@ def test_duplicate_tag():
|
|||
|
||||
|
||||
def test_custom_tag():
|
||||
class Foo(object): # noqa: B903, for Python2 compatibility
|
||||
class Foo: # noqa: B903, for Python2 compatibility
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_logging
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.regression
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -20,7 +19,7 @@ import flask
|
|||
_gc_lock = threading.Lock()
|
||||
|
||||
|
||||
class assert_no_leak(object):
|
||||
class assert_no_leak:
|
||||
def __enter__(self):
|
||||
gc.disable()
|
||||
_gc_lock.acquire()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.reqctx
|
||||
~~~~~~~~~~~~
|
||||
|
|
@ -150,7 +149,7 @@ def test_manual_context_binding(app):
|
|||
|
||||
|
||||
@pytest.mark.skipif(greenlet is None, reason="greenlet not installed")
|
||||
class TestGreenletContextCopying(object):
|
||||
class TestGreenletContextCopying:
|
||||
def test_greenlet_context_copying(self, app, client):
|
||||
greenlets = []
|
||||
|
||||
|
|
@ -239,7 +238,7 @@ def test_session_dynamic_cookie_name():
|
|||
if flask.request.url.endswith("dynamic_cookie"):
|
||||
return "dynamic_cookie_name"
|
||||
else:
|
||||
return super(PathAwareSessionInterface, self).get_cookie_name(app)
|
||||
return super().get_cookie_name(app)
|
||||
|
||||
class CustomFlask(flask.Flask):
|
||||
session_interface = PathAwareSessionInterface()
|
||||
|
|
@ -291,7 +290,7 @@ def test_bad_environ_raises_bad_request():
|
|||
environ = builder.get_environ()
|
||||
|
||||
# use a non-printable character in the Host - this is key to this test
|
||||
environ["HTTP_HOST"] = u"\x8a"
|
||||
environ["HTTP_HOST"] = "\x8a"
|
||||
|
||||
with app.request_context(environ):
|
||||
response = app.full_dispatch_request()
|
||||
|
|
@ -311,7 +310,7 @@ def test_environ_for_valid_idna_completes():
|
|||
environ = builder.get_environ()
|
||||
|
||||
# these characters are all IDNA-compatible
|
||||
environ["HTTP_HOST"] = u"ąśźäüжŠßя.com"
|
||||
environ["HTTP_HOST"] = "ąśźäüжŠßя.com"
|
||||
|
||||
with app.request_context(environ):
|
||||
response = app.full_dispatch_request()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.signals
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.subclassing
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.templating
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
@ -417,14 +416,14 @@ def test_template_loader_debugging(test_apps, monkeypatch):
|
|||
text = str(record.msg)
|
||||
assert '1: trying loader of application "blueprintapp"' in text
|
||||
assert (
|
||||
'2: trying loader of blueprint "admin" ' "(blueprintapp.apps.admin)"
|
||||
'2: trying loader of blueprint "admin" (blueprintapp.apps.admin)'
|
||||
) in text
|
||||
assert (
|
||||
'trying loader of blueprint "frontend" ' "(blueprintapp.apps.frontend)"
|
||||
'trying loader of blueprint "frontend" (blueprintapp.apps.frontend)'
|
||||
) in text
|
||||
assert "Error: the template could not be found" in text
|
||||
assert (
|
||||
"looked up from an endpoint that belongs to " 'the blueprint "frontend"'
|
||||
'looked up from an endpoint that belongs to the blueprint "frontend"'
|
||||
) in text
|
||||
assert "See https://flask.palletsprojects.com/blueprints/#templates" in text
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.testing
|
||||
~~~~~~~~~~~~~
|
||||
|
|
@ -122,8 +121,8 @@ def test_path_is_url(app):
|
|||
def test_environbuilder_json_dumps(app):
|
||||
"""EnvironBuilder.json_dumps() takes settings from the app."""
|
||||
app.config["JSON_AS_ASCII"] = False
|
||||
eb = EnvironBuilder(app, json=u"\u20ac")
|
||||
assert eb.input_stream.read().decode("utf8") == u'"\u20ac"'
|
||||
eb = EnvironBuilder(app, json="\u20ac")
|
||||
assert eb.input_stream.read().decode("utf8") == '"\u20ac"'
|
||||
|
||||
|
||||
def test_blueprint_with_subdomain():
|
||||
|
|
@ -324,7 +323,7 @@ def test_client_json_no_app_context(app, client):
|
|||
def hello():
|
||||
return "Hello, {}!".format(flask.request.json["name"])
|
||||
|
||||
class Namespace(object):
|
||||
class Namespace:
|
||||
count = 0
|
||||
|
||||
def add(self, app):
|
||||
|
|
@ -402,7 +401,7 @@ def test_cli_invoke(app):
|
|||
|
||||
|
||||
def test_cli_custom_obj(app):
|
||||
class NS(object):
|
||||
class NS:
|
||||
called = False
|
||||
|
||||
def create_app():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.test_user_error_handler
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -208,7 +207,7 @@ def test_default_error_handler():
|
|||
assert c.get("/slash", follow_redirects=True).data == b"slash"
|
||||
|
||||
|
||||
class TestGenericHandlers(object):
|
||||
class TestGenericHandlers:
|
||||
"""Test how very generic handlers are dispatched to."""
|
||||
|
||||
class Custom(Exception):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.views
|
||||
~~~~~~~~~~~
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue