Browse Source

add test and changelog for SERVER_NAME app.run default

ref #2152
pull/1493/merge
David Lord 8 years ago
parent
commit
42fbbb4cbb
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
  1. 2
      CHANGES
  2. 17
      tests/test_basic.py

2
CHANGES

@ -17,6 +17,8 @@ Bugfix release, unreleased
within the imported application module.
- Fix encoding behavior of ``app.config.from_pyfile`` for Python 3. Fix
``#2118``.
- Use the``SERVER_NAME`` config if it is present as default values for
``app.run``. ``#2109``, ``#2152``
Version 0.12
------------

17
tests/test_basic.py

@ -1681,3 +1681,20 @@ def test_run_server_port(monkeypatch):
hostname, port = 'localhost', 8000
app.run(hostname, port, debug=True)
assert rv['result'] == 'running on %s:%s ...' % (hostname, port)
@pytest.mark.parametrize('host,port,expect_host,expect_port', (
(None, None, 'pocoo.org', 8080),
('localhost', None, 'localhost', 8080),
(None, 80, 'pocoo.org', 80),
('localhost', 80, 'localhost', 80),
))
def test_run_from_config(monkeypatch, host, port, expect_host, expect_port):
def run_simple_mock(hostname, port, *args, **kwargs):
assert hostname == expect_host
assert port == expect_port
monkeypatch.setattr(werkzeug.serving, 'run_simple', run_simple_mock)
app = flask.Flask(__name__)
app.config['SERVER_NAME'] = 'pocoo.org:8080'
app.run(host, port)

Loading…
Cancel
Save