forked from orbit-oss/flask
Merge branch '1.0.x'
This commit is contained in:
commit
29111a3259
8 changed files with 35 additions and 65 deletions
|
|
@ -10,7 +10,6 @@ jobs:
|
||||||
python.architecture: 'x64'
|
python.architecture: 'x64'
|
||||||
TOXENV: 'py,coverage-ci'
|
TOXENV: 'py,coverage-ci'
|
||||||
publish.test.results: 'true'
|
publish.test.results: 'true'
|
||||||
CODECOV_TOKEN: '$(codecov.token)'
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/asottile/reorder_python_imports
|
- repo: https://github.com/asottile/reorder_python_imports
|
||||||
rev: v1.4.0
|
rev: v1.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: reorder-python-imports
|
- id: reorder-python-imports
|
||||||
name: Reorder Python imports (src, tests)
|
name: Reorder Python imports (src, tests)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ def with_metaclass(meta, *bases):
|
||||||
# dummy metaclass for one level of class instantiation that replaces
|
# dummy metaclass for one level of class instantiation that replaces
|
||||||
# itself with the actual metaclass.
|
# itself with the actual metaclass.
|
||||||
class metaclass(type):
|
class metaclass(type):
|
||||||
def __new__(mcs, name, this_bases, d):
|
def __new__(metacls, name, this_bases, d):
|
||||||
return meta(name, bases, d)
|
return meta(name, bases, d)
|
||||||
|
|
||||||
return type.__new__(metaclass, "temporary_class", (), {})
|
return type.__new__(metaclass, "temporary_class", (), {})
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
:copyright: © 2010 by the Pallets team.
|
:copyright: © 2010 by the Pallets team.
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
import gc
|
|
||||||
import os
|
import os
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -201,10 +200,3 @@ def purge_module(request):
|
||||||
request.addfinalizer(lambda: sys.modules.pop(name, None))
|
request.addfinalizer(lambda: sys.modules.pop(name, None))
|
||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def catch_deprecation_warnings(recwarn):
|
|
||||||
yield
|
|
||||||
gc.collect()
|
|
||||||
assert not recwarn.list, "\n".join(str(w.message) for w in recwarn.list)
|
|
||||||
|
|
|
||||||
|
|
@ -1475,60 +1475,46 @@ def test_request_locals():
|
||||||
assert not flask.g
|
assert not flask.g
|
||||||
|
|
||||||
|
|
||||||
def test_test_app_proper_environ():
|
def test_server_name_subdomain():
|
||||||
app = flask.Flask(__name__, subdomain_matching=True)
|
app = flask.Flask(__name__, subdomain_matching=True)
|
||||||
app.config.update(SERVER_NAME="localhost.localdomain:5000")
|
|
||||||
client = app.test_client()
|
client = app.test_client()
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return "Foo"
|
return "default"
|
||||||
|
|
||||||
@app.route("/", subdomain="foo")
|
@app.route("/", subdomain="foo")
|
||||||
def subdomain():
|
def subdomain():
|
||||||
return "Foo SubDomain"
|
return "subdomain"
|
||||||
|
|
||||||
|
app.config["SERVER_NAME"] = "dev.local:5000"
|
||||||
rv = client.get("/")
|
rv = client.get("/")
|
||||||
assert rv.data == b"Foo"
|
assert rv.data == b"default"
|
||||||
|
|
||||||
rv = client.get("/", "http://localhost.localdomain:5000")
|
rv = client.get("/", "http://dev.local:5000")
|
||||||
assert rv.data == b"Foo"
|
assert rv.data == b"default"
|
||||||
|
|
||||||
rv = client.get("/", "https://localhost.localdomain:5000")
|
rv = client.get("/", "https://dev.local:5000")
|
||||||
assert rv.data == b"Foo"
|
assert rv.data == b"default"
|
||||||
|
|
||||||
app.config.update(SERVER_NAME="localhost.localdomain")
|
app.config["SERVER_NAME"] = "dev.local:443"
|
||||||
rv = client.get("/", "https://localhost.localdomain")
|
rv = client.get("/", "https://dev.local")
|
||||||
assert rv.data == b"Foo"
|
|
||||||
|
|
||||||
try:
|
# Werkzeug 1.0 fixes matching https scheme with 443 port
|
||||||
app.config.update(SERVER_NAME="localhost.localdomain:443")
|
if rv.status_code != 404:
|
||||||
rv = client.get("/", "https://localhost.localdomain")
|
assert rv.data == b"default"
|
||||||
# Werkzeug 0.8
|
|
||||||
assert rv.status_code == 404
|
|
||||||
except ValueError as e:
|
|
||||||
# Werkzeug 0.7
|
|
||||||
assert str(e) == (
|
|
||||||
"the server name provided "
|
|
||||||
"('localhost.localdomain:443') does not match the "
|
|
||||||
"server name from the WSGI environment ('localhost.localdomain')"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
app.config["SERVER_NAME"] = "dev.local"
|
||||||
app.config.update(SERVER_NAME="localhost.localdomain")
|
rv = client.get("/", "https://dev.local")
|
||||||
|
assert rv.data == b"default"
|
||||||
|
|
||||||
|
# suppress Werkzeug 1.0 warning about name mismatch
|
||||||
|
with pytest.warns(None):
|
||||||
rv = client.get("/", "http://foo.localhost")
|
rv = client.get("/", "http://foo.localhost")
|
||||||
# Werkzeug 0.8
|
|
||||||
assert rv.status_code == 404
|
assert rv.status_code == 404
|
||||||
except ValueError as e:
|
|
||||||
# Werkzeug 0.7
|
|
||||||
assert str(e) == (
|
|
||||||
"the server name provided "
|
|
||||||
"('localhost.localdomain') does not match the "
|
|
||||||
"server name from the WSGI environment ('foo.localhost')"
|
|
||||||
)
|
|
||||||
|
|
||||||
rv = client.get("/", "http://foo.localhost.localdomain")
|
rv = client.get("/", "http://foo.dev.local")
|
||||||
assert rv.data == b"Foo SubDomain"
|
assert rv.data == b"subdomain"
|
||||||
|
|
||||||
|
|
||||||
def test_exception_propagation(app, client):
|
def test_exception_propagation(app, client):
|
||||||
|
|
@ -1885,9 +1871,11 @@ def test_subdomain_matching_other_name(matching):
|
||||||
def index():
|
def index():
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
# ip address can't match name
|
# suppress Werkzeug 0.15 warning about name mismatch
|
||||||
rv = client.get("/", "http://127.0.0.1:3000/")
|
with pytest.warns(None):
|
||||||
assert rv.status_code == 404 if matching else 204
|
# ip address can't match name
|
||||||
|
rv = client.get("/", "http://127.0.0.1:3000/")
|
||||||
|
assert rv.status_code == 404 if matching else 204
|
||||||
|
|
||||||
# allow all subdomains if matching is disabled
|
# allow all subdomains if matching is disabled
|
||||||
rv = client.get("/", "http://www.localhost.localdomain:3000/")
|
rv = client.get("/", "http://www.localhost.localdomain:3000/")
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ class TestSendfile(object):
|
||||||
assert rv.data == f.read()
|
assert rv.data == f.read()
|
||||||
rv.close()
|
rv.close()
|
||||||
|
|
||||||
def test_send_file_xsendfile(self, app, req_ctx, catch_deprecation_warnings):
|
def test_send_file_xsendfile(self, app, req_ctx):
|
||||||
app.use_x_sendfile = True
|
app.use_x_sendfile = True
|
||||||
rv = flask.send_file("static/index.html")
|
rv = flask.send_file("static/index.html")
|
||||||
assert rv.direct_passthrough
|
assert rv.direct_passthrough
|
||||||
|
|
|
||||||
|
|
@ -89,17 +89,12 @@ def test_proper_test_request_context(app):
|
||||||
== "http://foo.localhost.localdomain:5000/"
|
== "http://foo.localhost.localdomain:5000/"
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
# suppress Werkzeug 0.15 warning about name mismatch
|
||||||
|
with pytest.warns(None):
|
||||||
with app.test_request_context(
|
with app.test_request_context(
|
||||||
"/", environ_overrides={"HTTP_HOST": "localhost"}
|
"/", environ_overrides={"HTTP_HOST": "localhost"}
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
except ValueError as e:
|
|
||||||
assert str(e) == (
|
|
||||||
"the server name provided "
|
|
||||||
"('localhost.localdomain:5000') does not match the "
|
|
||||||
"server name from the WSGI environment ('localhost')"
|
|
||||||
)
|
|
||||||
|
|
||||||
app.config.update(SERVER_NAME="localhost")
|
app.config.update(SERVER_NAME="localhost")
|
||||||
with app.test_request_context("/", environ_overrides={"SERVER_NAME": "localhost"}):
|
with app.test_request_context("/", environ_overrides={"SERVER_NAME": "localhost"}):
|
||||||
|
|
|
||||||
10
tox.ini
10
tox.ini
|
|
@ -33,7 +33,7 @@ commands =
|
||||||
pip install -q -e examples/javascript[test]
|
pip install -q -e examples/javascript[test]
|
||||||
|
|
||||||
# pytest-cov doesn't seem to play nice with -p
|
# pytest-cov doesn't seem to play nice with -p
|
||||||
coverage run -p -m pytest --tb=short {posargs:tests examples}
|
coverage run -p -m pytest --tb=short -Werror {posargs:tests examples}
|
||||||
|
|
||||||
[testenv:nightly]
|
[testenv:nightly]
|
||||||
# courtesy Python nightly test, don't fail the build in CI
|
# courtesy Python nightly test, don't fail the build in CI
|
||||||
|
|
@ -41,7 +41,7 @@ ignore_outcome = true
|
||||||
commands =
|
commands =
|
||||||
pip install -q -e examples/tutorial[test]
|
pip install -q -e examples/tutorial[test]
|
||||||
pip install -q -e examples/javascript[test]
|
pip install -q -e examples/javascript[test]
|
||||||
coverage run -p -m pytest --tb=short --junitxml=test-results.xml {posargs:tests examples}
|
coverage run -p -m pytest --tb=short -Werror --junitxml=test-results.xml {posargs:tests examples}
|
||||||
|
|
||||||
[testenv:stylecheck]
|
[testenv:stylecheck]
|
||||||
deps = pre-commit
|
deps = pre-commit
|
||||||
|
|
@ -62,13 +62,9 @@ commands =
|
||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
[testenv:coverage-ci]
|
[testenv:coverage-ci]
|
||||||
passenv = CODECOV_TOKEN
|
deps = coverage
|
||||||
deps =
|
|
||||||
coverage
|
|
||||||
codecov
|
|
||||||
skip_install = true
|
skip_install = true
|
||||||
commands =
|
commands =
|
||||||
coverage combine
|
coverage combine
|
||||||
codecov
|
|
||||||
coverage xml
|
coverage xml
|
||||||
coverage report
|
coverage report
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue