From 6b47863c89147d06f775355cc827d9b6ddb0b2c4 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Wed, 4 Feb 2015 01:03:10 -0500 Subject: [PATCH] DEV: Make callable used to create a Process configurable. Allows users to specify an alternate callable to produce an object with the same interface as a multiprocessing.Process. Most notably, this is useful for spawning a server with a subclass of multiprocessing.Process, such as the Gevent-aware Process subclass implemented by [gipc](https://bitbucket.org/jgehrcke/gipc). --- flask_testing/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flask_testing/utils.py b/flask_testing/utils.py index add12ef..bc6d2e2 100644 --- a/flask_testing/utils.py +++ b/flask_testing/utils.py @@ -336,6 +336,9 @@ def assert500(self, response, message=None): # Inspired by https://docs.djangoproject.com/en/dev/topics/testing/#django.test.LiveServerTestCase class LiveServerTestCase(unittest.TestCase): + + process_factory = multiprocessing.Process + def create_app(self): """ Create your Flask app here, with any @@ -375,7 +378,7 @@ def _spawn_live_server(self): worker = lambda app, port: app.run(port=port, use_reloader=False) - self._process = multiprocessing.Process( + self._process = self.process_factory( target=worker, args=(self.app, self.port) )