|
|
@ -1681,3 +1681,20 @@ def test_run_server_port(monkeypatch): |
|
|
|
hostname, port = 'localhost', 8000 |
|
|
|
hostname, port = 'localhost', 8000 |
|
|
|
app.run(hostname, port, debug=True) |
|
|
|
app.run(hostname, port, debug=True) |
|
|
|
assert rv['result'] == 'running on %s:%s ...' % (hostname, port) |
|
|
|
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) |
|
|
|