Commit c1826a80 authored by Alexandros Afentoulis's avatar Alexandros Afentoulis

New upstream version 0.14.0

parent e650bdb5
Metadata-Version: 2.1
Name: pytest-flask
Version: 0.13.0
Version: 0.14.0
Summary: A set of py.test fixtures to test Flask applications.
Home-page: https://github.com/vitalk/pytest-flask
Author: Vital Kudzelka
Author-email: vital.kudzelka@gmail.com
License: MIT
Project-URL: Source, https://github.com/pytest-dev/pytest-flask
Project-URL: Tracker, https://github.com/pytest-dev/pytest-flask/issues
Project-URL: Source, https://github.com/pytest-dev/pytest-flask
Description:
pytest-flask
============
......
......@@ -28,7 +28,7 @@ Define your application fixture in ``conftest.py``:
Install the extension with dependencies and go::
$ pip install pytest-flask
$ py.test
$ pytest
Contributing
------------
......
......@@ -3,6 +3,17 @@
Changelog
=========
0.14.0 (2018-10-15)
-------------------
- New ``--live-server-host`` command-line option to set the host name used by
the ``live_server`` fixture.
Thanks `@o1da`_ for the PR (`#90`_).
.. _@o1da: https://github.com/o1da
.. _#90: https://github.com/pytest-dev/pytest-flask/pull/90
0.13.0 (2018-09-29)
-------------------
......
Metadata-Version: 2.1
Name: pytest-flask
Version: 0.13.0
Version: 0.14.0
Summary: A set of py.test fixtures to test Flask applications.
Home-page: https://github.com/vitalk/pytest-flask
Author: Vital Kudzelka
Author-email: vital.kudzelka@gmail.com
License: MIT
Project-URL: Source, https://github.com/pytest-dev/pytest-flask
Project-URL: Tracker, https://github.com/pytest-dev/pytest-flask/issues
Project-URL: Source, https://github.com/pytest-dev/pytest-flask
Description:
pytest-flask
============
......
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '0.13.0'
version = '0.14.0'
......@@ -50,22 +50,24 @@ class LiveServer(object):
stopping application in a separate process.
:param app: The application to run.
:param host: The host where to listen (default localhost).
:param port: The port to run application.
"""
def __init__(self, app, port, clean_stop=False):
def __init__(self, app, host, port, clean_stop=False):
self.app = app
self.port = port
self.host = host
self.clean_stop = clean_stop
self._process = None
def start(self):
"""Start application in a separate process."""
def worker(app, port):
app.run(port=port, use_reloader=False, threaded=True)
def worker(app, host, port):
app.run(host=host, port=port, use_reloader=False, threaded=True)
self._process = multiprocessing.Process(
target=worker,
args=(self.app, self.port)
args=(self.app, self.host, self.port)
)
self._process.start()
......@@ -82,7 +84,7 @@ class LiveServer(object):
def url(self, url=''):
"""Returns the complete url based on server options."""
return 'http://localhost:%d%s' % (self.port, url)
return 'http://%s:%d%s' % (self.host, self.port, url)
def stop(self):
"""Stop application process."""
......@@ -143,6 +145,8 @@ def live_server(request, app, monkeypatch, pytestconfig):
port = s.getsockname()[1]
s.close()
host = pytestconfig.getvalue('live_server_host')
# Explicitly set application ``SERVER_NAME`` for test suite
# and restore original value on test teardown.
server_name = app.config['SERVER_NAME'] or 'localhost'
......@@ -150,7 +154,7 @@ def live_server(request, app, monkeypatch, pytestconfig):
_rewrite_server_name(server_name, str(port)))
clean_stop = request.config.getvalue('live_server_clean_stop')
server = LiveServer(app, port, clean_stop)
server = LiveServer(app, host, port, clean_stop)
if request.config.getvalue('start_live_server'):
server.start()
......
......@@ -161,6 +161,8 @@ def pytest_addoption(parser):
group.addoption('--no-live-server-clean-stop',
action="store_false", dest="live_server_clean_stop",
help="terminate the server forcefully after stop.")
group.addoption('--live-server-host', action='store', default='localhost', type=str,
help='use a host where to listen (default localhost).')
group.addoption('--live-server-port', action='store', default=0, type=int,
help='use a fixed port for the live_server fixture.')
......
......@@ -182,3 +182,15 @@ class TestLiveServer:
result = appdir.runpytest('-v', '--live-server-port', str(port))
result.stdout.fnmatch_lines(['*PASSED*'])
assert result.ret == 0
@pytest.mark.parametrize('host', ['127.0.0.1', '0.0.0.0'])
def test_live_server_fixed_host(self, host, appdir):
appdir.create_test_module('''
import pytest
def test_port(live_server):
assert live_server.host == '%s'
''' % host)
result = appdir.runpytest('-v', '--live-server-host', str(host))
result.stdout.fnmatch_lines(['*PASSED*'])
assert result.ret == 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment