diff options
| author | Gabriel Falcao <gabriel@nacaolivre.org> | 2013-10-01 18:56:34 -0400 |
|---|---|---|
| committer | Gabriel Falcao <gabriel@nacaolivre.org> | 2013-10-01 18:56:34 -0400 |
| commit | 2abe6693d72ca7308d45c2aef2721caa9c6cb8f1 (patch) | |
| tree | 93591561960dbd052c830d383bec1c417d9e7d2f /tests | |
| parent | 53833be96be8b1cb36d30ffd15e7cc93c34ddacf (diff) | |
| download | httpretty-2abe6693d72ca7308d45c2aef2721caa9c6cb8f1.tar.gz | |
using threads in the base server instead of multiprocessing and removing the fake server's port from POTENTIAL_HTTP_PORTS in the end of the test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/base.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/functional/base.py b/tests/functional/base.py index 43d64fc..6da37e1 100644 --- a/tests/functional/base.py +++ b/tests/functional/base.py @@ -27,7 +27,7 @@ from __future__ import unicode_literals import os -import multiprocessing +import threading import traceback import tornado.ioloop import tornado.web @@ -35,6 +35,7 @@ from functools import wraps from sure import scenario import json from os.path import abspath, dirname, join +from httpretty.core import POTENTIAL_HTTP_PORTS LOCAL_FILE = lambda *path: join(abspath(dirname(__file__)), *path) @@ -51,10 +52,10 @@ class JSONEchoHandler(tornado.web.RequestHandler): self.write(json.dumps({matched or 'index': payload}, indent=4)) -class JSONEchoServer(multiprocessing.Process): +class JSONEchoServer(threading.Thread): def __init__(self, port=8888, *args, **kw): self.port = int(port) - self._stop = multiprocessing.Event() + self._stop = threading.Event() super(JSONEchoServer, self).__init__(*args, **kw) self.daemon = True @@ -85,5 +86,6 @@ def use_tornado_server(callback): callback(*args, **kw) finally: server.stop() - + if 8888 in POTENTIAL_HTTP_PORTS: + POTENTIAL_HTTP_PORTS.remove(8888) return func |
