summaryrefslogtreecommitdiff
path: root/waitress/tests/test_task.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-07-06 13:25:15 -0400
committerChris McDonough <chrism@plope.com>2012-07-06 13:25:15 -0400
commite4051f87347c866f7d66399dc91315ab862fd411 (patch)
treeeafcc1f76ad7389b999db19eb4a89ed996aa1324 /waitress/tests/test_task.py
parente18bbfde117c8449cf67f9a3f14dd00b3cd93cd2 (diff)
downloadwaitress-fix.idemonkeys.tar.gz
- Appease IDEs that want to monkeypatch the thread module by changing afix.idemonkeys
testing pattern. With any luck, the following will no longer be a problem: http://devnet.jetbrains.net/thread/433486
Diffstat (limited to 'waitress/tests/test_task.py')
-rw-r--r--waitress/tests/test_task.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/waitress/tests/test_task.py b/waitress/tests/test_task.py
index 1493b21..3d88cd2 100644
--- a/waitress/tests/test_task.py
+++ b/waitress/tests/test_task.py
@@ -29,19 +29,19 @@ class TestThreadedTaskDispatcher(unittest.TestCase):
def test_set_thread_count_increase(self):
inst = self._makeOne()
- L = []
- inst.start_new_thread = lambda *x: L.append(x)
+ mod = DummyThreadModule()
+ inst.thread_module = mod
inst.set_thread_count(1)
- self.assertEqual(L, [(inst.handler_thread, (0,))])
+ self.assertEqual(mod.threads, [(inst.handler_thread, (0,))])
def test_set_thread_count_increase_with_existing(self):
inst = self._makeOne()
- L = []
+ mod = DummyThreadModule()
+ inst.thread_module = mod
inst.threads = {0:1}
- inst.start_new_thread = lambda *x: L.append(x)
inst.set_thread_count(2)
- self.assertEqual(L, [(inst.handler_thread, (1,))])
-
+ self.assertEqual(mod.threads, [(inst.handler_thread, (1,))])
+
def test_set_thread_count_decrease(self):
inst = self._makeOne()
inst.threads = {'a':1, 'b':2}
@@ -51,11 +51,11 @@ class TestThreadedTaskDispatcher(unittest.TestCase):
def test_set_thread_count_same(self):
inst = self._makeOne()
- L = []
- inst.start_new_thread = lambda *x: L.append(x)
+ mod = DummyThreadModule()
+ inst.thread_module = mod
inst.threads = {0:1}
inst.set_thread_count(1)
- self.assertEqual(L, [])
+ self.assertEqual(mod.threads, [])
def test_add_task(self):
task = DummyTask()
@@ -684,3 +684,9 @@ class DummyLogger(object):
def exception(self, msg):
self.logged.append(msg)
+class DummyThreadModule(object):
+ def __init__(self):
+ self.threads = []
+ def start_new_thread(self, *x):
+ self.threads.append(x)
+