forked from orbit-oss/flask
remove _compat module
This commit is contained in:
parent
1263d3bd14
commit
662c245795
20 changed files with 68 additions and 274 deletions
|
|
@ -24,7 +24,6 @@ from werkzeug.http import parse_date
|
|||
from werkzeug.routing import BuildError
|
||||
|
||||
import flask
|
||||
from flask._compat import text_type
|
||||
|
||||
|
||||
def test_options_work(app, client):
|
||||
|
|
@ -413,7 +412,7 @@ def test_session_expiration(app, client):
|
|||
|
||||
@app.route("/test")
|
||||
def test():
|
||||
return text_type(flask.session.permanent)
|
||||
return str(flask.session.permanent)
|
||||
|
||||
rv = client.get("/")
|
||||
assert "set-cookie" in rv.headers
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from jinja2 import TemplateNotFound
|
|||
from werkzeug.http import parse_cache_control_header
|
||||
|
||||
import flask
|
||||
from flask._compat import text_type
|
||||
|
||||
|
||||
def test_blueprint_specific_error_handling(app, client):
|
||||
|
|
@ -150,7 +149,7 @@ def test_blueprint_url_defaults(app, client):
|
|||
|
||||
@bp.route("/bar")
|
||||
def bar(bar):
|
||||
return text_type(bar)
|
||||
return str(bar)
|
||||
|
||||
app.register_blueprint(bp, url_prefix="/1", url_defaults={"bar": 23})
|
||||
app.register_blueprint(bp, url_prefix="/2", url_defaults={"bar": 19})
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
import flask
|
||||
from flask._compat import PY2
|
||||
|
||||
|
||||
# config keys used for the TestConfig
|
||||
|
|
@ -198,6 +197,4 @@ def test_from_pyfile_weird_encoding(tmpdir, encoding):
|
|||
app = flask.Flask(__name__)
|
||||
app.config.from_pyfile(str(f))
|
||||
value = app.config["TEST_VALUE"]
|
||||
if PY2:
|
||||
value = value.decode(encoding)
|
||||
assert value == u"föö"
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ from werkzeug.http import parse_options_header
|
|||
|
||||
import flask
|
||||
from flask import json
|
||||
from flask._compat import PY2
|
||||
from flask._compat import StringIO
|
||||
from flask._compat import text_type
|
||||
from flask.helpers import get_debug_flag
|
||||
from flask.helpers import get_env
|
||||
|
||||
|
|
@ -116,7 +113,7 @@ class TestJSON(object):
|
|||
def test_json_bad_requests(self, app, client):
|
||||
@app.route("/json", methods=["POST"])
|
||||
def return_json():
|
||||
return flask.jsonify(foo=text_type(flask.request.get_json()))
|
||||
return flask.jsonify(foo=str(flask.request.get_json()))
|
||||
|
||||
rv = client.post("/json", data="malformed", content_type="application/json")
|
||||
assert rv.status_code == 400
|
||||
|
|
@ -140,7 +137,7 @@ class TestJSON(object):
|
|||
|
||||
def test_json_dump_to_file(self, app, app_ctx):
|
||||
test_data = {"name": "Flask"}
|
||||
out = StringIO()
|
||||
out = io.StringIO()
|
||||
|
||||
flask.json.dump(test_data, out)
|
||||
out.seek(0)
|
||||
|
|
@ -254,7 +251,7 @@ class TestJSON(object):
|
|||
@app.route("/add", methods=["POST"])
|
||||
def add():
|
||||
json = flask.request.get_json()
|
||||
return text_type(json["a"] + json["b"])
|
||||
return str(json["a"] + json["b"])
|
||||
|
||||
rv = client.post(
|
||||
"/add",
|
||||
|
|
@ -267,7 +264,7 @@ class TestJSON(object):
|
|||
render = flask.render_template_string
|
||||
rv = flask.json.htmlsafe_dumps("</script>")
|
||||
assert rv == u'"\\u003c/script\\u003e"'
|
||||
assert type(rv) == text_type
|
||||
assert type(rv) is str
|
||||
rv = render('{{ "</script>"|tojson }}')
|
||||
assert rv == '"\\u003c/script\\u003e"'
|
||||
rv = render('{{ "<\0/script>"|tojson }}')
|
||||
|
|
@ -447,7 +444,7 @@ class TestJSON(object):
|
|||
assert lines == sorted_by_str
|
||||
|
||||
|
||||
class PyStringIO(object):
|
||||
class PyBytesIO(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._io = io.BytesIO(*args, **kwargs)
|
||||
|
||||
|
|
@ -503,11 +500,7 @@ class TestSendfile(object):
|
|||
[
|
||||
lambda app: open(os.path.join(app.static_folder, "index.html"), "rb"),
|
||||
lambda app: io.BytesIO(b"Test"),
|
||||
pytest.param(
|
||||
lambda app: StringIO("Test"),
|
||||
marks=pytest.mark.skipif(not PY2, reason="Python 2 only"),
|
||||
),
|
||||
lambda app: PyStringIO(b"Test"),
|
||||
lambda app: PyBytesIO(b"Test"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("req_ctx")
|
||||
|
|
@ -525,10 +518,7 @@ class TestSendfile(object):
|
|||
"opener",
|
||||
[
|
||||
lambda app: io.StringIO(u"Test"),
|
||||
pytest.param(
|
||||
lambda app: open(os.path.join(app.static_folder, "index.html")),
|
||||
marks=pytest.mark.skipif(PY2, reason="Python 3 only"),
|
||||
),
|
||||
lambda app: open(os.path.join(app.static_folder, "index.html")),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("req_ctx")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import sys
|
|||
import pytest
|
||||
|
||||
import flask
|
||||
from flask._compat import PY2
|
||||
|
||||
|
||||
def test_explicit_instance_paths(modules_tmpdir):
|
||||
|
|
@ -128,19 +127,3 @@ def test_egg_installed_paths(install_egg, modules_tmpdir, modules_tmpdir_prefix)
|
|||
finally:
|
||||
if "site_egg" in sys.modules:
|
||||
del sys.modules["site_egg"]
|
||||
|
||||
|
||||
@pytest.mark.skipif(not PY2, reason="This only works under Python 2.")
|
||||
def test_meta_path_loader_without_is_package(request, modules_tmpdir):
|
||||
app = modules_tmpdir.join("unimportable.py")
|
||||
app.write("import flask\napp = flask.Flask(__name__)")
|
||||
|
||||
class Loader(object):
|
||||
def find_module(self, name, path=None):
|
||||
return self
|
||||
|
||||
sys.meta_path.append(Loader())
|
||||
request.addfinalizer(sys.meta_path.pop)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
import unimportable # noqa: F401
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ tests.test_logging
|
|||
"""
|
||||
import logging
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
import pytest
|
||||
|
||||
from flask._compat import StringIO
|
||||
from flask.logging import default_handler
|
||||
from flask.logging import has_level_handler
|
||||
from flask.logging import wsgi_errors_stream
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
import io
|
||||
|
||||
|
||||
def test_changelog_utf8_compatible():
|
||||
with io.open("CHANGES.rst", encoding="UTF-8") as f:
|
||||
f.read()
|
||||
|
|
@ -9,8 +9,9 @@
|
|||
:copyright: 2010 Pallets
|
||||
:license: BSD-3-Clause
|
||||
"""
|
||||
from io import StringIO
|
||||
|
||||
import flask
|
||||
from flask._compat import StringIO
|
||||
|
||||
|
||||
def test_suppressed_exception_logging():
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import werkzeug
|
|||
|
||||
import flask
|
||||
from flask import appcontext_popped
|
||||
from flask._compat import text_type
|
||||
from flask.cli import ScriptInfo
|
||||
from flask.json import jsonify
|
||||
from flask.testing import EnvironBuilder
|
||||
|
|
@ -184,7 +183,7 @@ def test_redirect_keep_session(app, client, app_ctx):
|
|||
def test_session_transactions(app, client):
|
||||
@app.route("/")
|
||||
def index():
|
||||
return text_type(flask.session["foo"])
|
||||
return str(flask.session["foo"])
|
||||
|
||||
with client:
|
||||
with client.session_transaction() as sess:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue