Merge branch '1.0.x'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parents d4b688b, 8a7d080 · Browse files · 8 files·+35 added−65 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+35 added−65 removed
- tests:+30 added−55 removed
- other:+5 added−10 removed
Provenance
- Commit
29111a3- Tree
f4f5356- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
d4b688b- Parent 2
8a7d080
8 files changed+35 added−65 removed
modified:src/flask/_compat.py+1 added-1 removed
61 unmodified lines62 # This requires a bit of explanation: the basic idea is to make a63 # dummy metaclass for one level of class instantiation that replaces64 # itself with the actual metaclass.65 class metaclass(type):66- def __new__(mcs, name, this_bases, d):66+ def __new__(metacls, name, this_bases, d):67 return meta(name, bases, d)68 69 return type.__new__(metaclass, "temporary_class", (), {})70 45 unmodified linesmodified:tests/conftest.py-8 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-import gc9 import os10 import pkgutil11 import sys12 import textwrap186 unmodified lines199 def inner(name):200 request.addfinalizer(lambda: sys.modules.pop(name, None))201 202 return inner204-205-206-@pytest.fixture(autouse=True)207-def catch_deprecation_warnings(recwarn):208- yield209- gc.collect()210- assert not recwarn.list, "\n".join(str(w.message) for w in recwarn.list)modified:tests/test_basic.py+27 added-39 removed
1473 unmodified lines1474 assert repr(flask.g) == "<LocalProxy unbound>"1475 assert not flask.g1476 1477 1478-def test_test_app_proper_environ():1478+def test_server_name_subdomain():1479 app = flask.Flask(__name__, subdomain_matching=True)1480- app.config.update(SERVER_NAME="localhost.localdomain:5000")1480 client = app.test_client()1481 1482 @app.route("/")1483 def index():1485- return "Foo"1484+ return "default"1485 1486 @app.route("/", subdomain="foo")1487 def subdomain():1489- return "Foo SubDomain"1488+ return "subdomain"1489 1490+ app.config["SERVER_NAME"] = "dev.local:5000"1491 rv = client.get("/")1492- assert rv.data == b"Foo"1492+ assert rv.data == b"default"1493 1494- rv = client.get("/", "http://localhost.localdomain:5000")1495- assert rv.data == b"Foo"1494+ rv = client.get("/", "http://dev.local:5000")1495+ assert rv.data == b"default"1496 1497- rv = client.get("/", "https://localhost.localdomain:5000")1498- assert rv.data == b"Foo"1497+ rv = client.get("/", "https://dev.local:5000")1498+ assert rv.data == b"default"1499 1500- app.config.update(SERVER_NAME="localhost.localdomain")1501- rv = client.get("/", "https://localhost.localdomain")1502- assert rv.data == b"Foo"1500+ app.config["SERVER_NAME"] = "dev.local:443"1501+ rv = client.get("/", "https://dev.local")1502 1504- try:1505- app.config.update(SERVER_NAME="localhost.localdomain:443")1506- rv = client.get("/", "https://localhost.localdomain")1507- # Werkzeug 0.81508- assert rv.status_code == 4041509- except ValueError as e:1510- # Werkzeug 0.71511- assert str(e) == (1512- "the server name provided "1513- "('localhost.localdomain:443') does not match the "1514- "server name from the WSGI environment ('localhost.localdomain')"1515- )1503+ # Werkzeug 1.0 fixes matching https scheme with 443 port1504+ if rv.status_code != 404:1505+ assert rv.data == b"default"1506 1517- try:1518- app.config.update(SERVER_NAME="localhost.localdomain")1507+ app.config["SERVER_NAME"] = "dev.local"1508+ rv = client.get("/", "https://dev.local")1509+ assert rv.data == b"default"1510+1511+ # suppress Werkzeug 1.0 warning about name mismatch1512+ with pytest.warns(None):1513 rv = client.get("/", "http://foo.localhost")1520- # Werkzeug 0.81514 assert rv.status_code == 4041522- except ValueError as e:1523- # Werkzeug 0.71524- assert str(e) == (1525- "the server name provided "1526- "('localhost.localdomain') does not match the "1527- "server name from the WSGI environment ('foo.localhost')"1528- )1515 1530- rv = client.get("/", "http://foo.localhost.localdomain")1531- assert rv.data == b"Foo SubDomain"1516+ rv = client.get("/", "http://foo.dev.local")1517+ assert rv.data == b"subdomain"1518 1519 1520 def test_exception_propagation(app, client):1521 def apprunner(config_key):348 unmodified lines1870 @app.route("/")1871 def index():1872 return "", 2041873 1874+ # suppress Werkzeug 0.15 warning about name mismatch1875+ with pytest.warns(None):1888- # ip address can't match name1889- rv = client.get("/", "http://127.0.0.1:3000/")1890- assert rv.status_code == 404 if matching else 2041876+ # ip address can't match name1877+ rv = client.get("/", "http://127.0.0.1:3000/")1878+ assert rv.status_code == 404 if matching else 2041879 1880 # allow all subdomains if matching is disabled1881 rv = client.get("/", "http://www.localhost.localdomain:3000/")1882 assert rv.status_code == 404 if matching else 204107 unmodified linesmodified:tests/test_helpers.py+1 added-1 removed
453 unmodified lines454 rv.direct_passthrough = False455 assert rv.data == f.read()456 rv.close()457 458- def test_send_file_xsendfile(self, app, req_ctx, catch_deprecation_warnings):458+ def test_send_file_xsendfile(self, app, req_ctx):459 app.use_x_sendfile = True460 rv = flask.send_file("static/index.html")461 assert rv.direct_passthrough462 assert "x-sendfile" in rv.headers580 unmodified linesmodified:tests/test_reqctx.py+2 added-7 removed
87 unmodified lines88 flask.url_for("sub", _external=True)89 == "http://foo.localhost.localdomain:5000/"90 )91 92- try:92+ # suppress Werkzeug 0.15 warning about name mismatch93+ with pytest.warns(None):94 with app.test_request_context(95 "/", environ_overrides={"HTTP_HOST": "localhost"}96 ):97 pass97- except ValueError as e:98- assert str(e) == (99- "the server name provided "100- "('localhost.localdomain:5000') does not match the "101- "server name from the WSGI environment ('localhost')"102- )98 99 app.config.update(SERVER_NAME="localhost")100 with app.test_request_context("/", environ_overrides={"SERVER_NAME": "localhost"}):101 pass184 unmodified linesmodified:.azure-pipelines.yml-1 removed
8 unmodified lines9101112131314151671 unmodified lines8 unmodified lines python.version: '3.7' python.architecture: 'x64' TOXENV: 'py,coverage-ci' publish.test.results: 'true' CODECOV_TOKEN: '$(codecov.token)'
strategy: matrix: Python37Linux:71 unmodified linesmodified:.pre-commit-config.yaml+1 added-1 removed
1233456716 unmodified linesrepos: - repo: https://github.com/asottile/reorder_python_imports rev: v1.4.0 rev: v1.5.0 hooks: - id: reorder-python-imports name: Reorder Python imports (src, tests) files: "^(?!examples/)"16 unmodified linesmodified:tox.ini+3 added-7 removed
31 unmodified lines32 pip install -q -e examples/tutorial[test]33 pip install -q -e examples/javascript[test]34 35 # pytest-cov doesn't seem to play nice with -p36- coverage run -p -m pytest --tb=short {posargs:tests examples}36+ coverage run -p -m pytest --tb=short -Werror {posargs:tests examples}37 38 [testenv:nightly]39 # courtesy Python nightly test, don't fail the build in CI40 ignore_outcome = true41 commands =42 pip install -q -e examples/tutorial[test]43 pip install -q -e examples/javascript[test]44- coverage run -p -m pytest --tb=short --junitxml=test-results.xml {posargs:tests examples}44+ coverage run -p -m pytest --tb=short -Werror --junitxml=test-results.xml {posargs:tests examples}45 46 [testenv:stylecheck]47 deps = pre-commit48 skip_install = true12 unmodified lines61 coverage html62 coverage report63 64 [testenv:coverage-ci]65-passenv = CODECOV_TOKEN66-deps =67- coverage65+deps = coverage68- codecov66 skip_install = true67 commands =68 coverage combine72- codecov69 coverage xml70 coverage report