| Index: tests/utils.py |
| diff --git a/tests/utils.py b/tests/utils.py |
| index ed21e24c650e59651cd2a6edcf9d1cd915c9a38e..fda4cfe4f55d6be0ff314b41ec58445c5faf7c4f 100644 |
| --- a/tests/utils.py |
| +++ b/tests/utils.py |
| @@ -37,20 +37,35 @@ def get_dir_contents(path): |
| @contextlib.contextmanager |
| -def run_test_server(site_path): |
| +def run_test_server(site_path, new_env=None): |
| """Run test server, yield its URL. Terminate server on next iteration. |
| This function is intended be used in a pytest fixture. |
| + |
| + Parameters |
| + ---------- |
| + site_path: str |
| + The path to the website's source code. |
| + new_env: dict |
| + The environment under which the server will be run. If `None`, this |
| + will be inherited from the main process. |
| + |
| + Returns |
| + ------- |
| + str |
| + The url where the server runs. |
| + |
| """ |
| args = ['python', 'runserver.py', site_path] |
| # Werkzeug is a dependency of flask which we are using for the mock api |
| # however there is an issue with Werkzeug that prevents it from properly |
| # handling the SIGTERM sent by p.kill() or terminate() |
| # Issue: https://github.com/pallets/werkzeug/issues/58 |
| - p = subprocess.Popen(args, stdout=subprocess.PIPE, preexec_fn=os.setsid) |
| + p = subprocess.Popen(args, stdout=subprocess.PIPE, preexec_fn=os.setsid, |
| + env=new_env) |
| time.sleep(0.5) |
| yield 'http://localhost:5000/' |
| - os.killpg(os.getpgid(p.pid), signal.SIGTERM) |
| + os.killpg(os.getpgid(p.pid), signal.SIGINT) |
| def create_in_memory_zip(file_names, file_data): |