From 8e4b59972424996f75097785e557849e93c6bd70 Mon Sep 17 00:00:00 2001 From: Vital Kudzelka Date: Fri, 9 Dec 2016 20:50:41 +0300 Subject: [PATCH] Move application worker definition to the top level of a module As per https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled the only top level function can be pickled. Re #54. --- pytest_flask/fixtures.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pytest_flask/fixtures.py b/pytest_flask/fixtures.py index b8dd228..4b33fa9 100755 --- a/pytest_flask/fixtures.py +++ b/pytest_flask/fixtures.py @@ -41,6 +41,10 @@ def test_login(self): request.cls.client = client +def _app_worker(app, port): + app.run(port=port, use_reloader=False) + + class LiveServer(object): """The helper class uses to manage live server. Handles creation and stopping application in a separate process. @@ -56,10 +60,8 @@ def __init__(self, app, port): def start(self): """Start application in a separate process.""" - def worker(app, port): - app.run(port=port, use_reloader=False) self._process = multiprocessing.Process( - target=worker, + target=_app_worker, args=(self.app, self.port) ) self._process.start()