Skip to content
Myr

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

8 files+35 added−65 removed

modified:src/flask/_compat.py+1 added-1 removed
61 unmodified lines
62 # 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)6869 return type.__new__(metaclass, "temporary_class", (), {})70
45 unmodified lines
modified:tests/conftest.py-8 removed
4 unmodified lines
56 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8"""9import gc9import os10import pkgutil11import sys12import textwrap
186 unmodified lines
199 def inner(name):200 request.addfinalizer(lambda: sys.modules.pop(name, None))201202 return inner204205206@pytest.fixture(autouse=True)207def 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 lines
1474 assert repr(flask.g) == "<LocalProxy unbound>"1475 assert not flask.g147614771478def test_test_app_proper_environ():1478def 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()14811482 @app.route("/")1483 def index():1485 return "Foo"1484 return "default"14851486 @app.route("/", subdomain="foo")1487 def subdomain():1489 return "Foo SubDomain"1488 return "subdomain"14891490 app.config["SERVER_NAME"] = "dev.local:5000"1491 rv = client.get("/")1492 assert rv.data == b"Foo"1492 assert rv.data == b"default"14931494 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"14961497 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"14991500 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")15021504 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"15061517 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"15101511 # 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 )15151530 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"151815191520def test_exception_propagation(app, client):1521 def apprunner(config_key):
348 unmodified lines
1870 @app.route("/")1871 def index():1872 return "", 20418731874 # 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 20418791880 # allow all subdomains if matching is disabled1881 rv = client.get("/", "http://www.localhost.localdomain:3000/")1882 assert rv.status_code == 404 if matching else 204
107 unmodified lines
modified:tests/test_helpers.py+1 added-1 removed
453 unmodified lines
454 rv.direct_passthrough = False455 assert rv.data == f.read()456 rv.close()457458 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.headers
580 unmodified lines
modified:tests/test_reqctx.py+2 added-7 removed
87 unmodified lines
88 flask.url_for("sub", _external=True)89 == "http://foo.localhost.localdomain:5000/"90 )9192 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 )9899 app.config.update(SERVER_NAME="localhost")100 with app.test_request_context("/", environ_overrides={"SERVER_NAME": "localhost"}):101 pass
184 unmodified lines
modified:.azure-pipelines.yml-1 removed
modified:.pre-commit-config.yaml+1 added-1 removed
modified:tox.ini+3 added-7 removed
31 unmodified lines
32 pip install -q -e examples/tutorial[test]33 pip install -q -e examples/javascript[test]3435 # 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}3738[testenv:nightly]39# courtesy Python nightly test, don't fail the build in CI40ignore_outcome = true41commands =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}4546[testenv:stylecheck]47deps = pre-commit48skip_install = true
12 unmodified lines
61 coverage html62 coverage report6364[testenv:coverage-ci]65passenv = CODECOV_TOKEN66deps =67 coverage65deps = coverage68 codecov66skip_install = true67commands =68 coverage combine72 codecov69 coverage xml70 coverage report