Merge lp:~verterok/txstatsd/use-mock-instead-of-mocker into lp:txstatsd
- use-mock-instead-of-mocker
- Merge into trunk
Proposed by
Guillermo Gonzalez
Status: | Merged |
---|---|
Approved by: | Sidnei da Silva |
Approved revision: | 105 |
Merged at revision: | 105 |
Proposed branch: | lp:~verterok/txstatsd/use-mock-instead-of-mocker |
Merge into: | lp:txstatsd |
Diff against target: |
339 lines (+82/-98) 3 files modified
requirements.txt (+1/-1) txstatsd/tests/test_client.py (+24/-28) txstatsd/tests/test_process.py (+57/-69) |
To merge this branch: | bzr merge lp:~verterok/txstatsd/use-mock-instead-of-mocker |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sidnei da Silva | Approve | ||
Review via email: mp+152206@code.launchpad.net |
Commit message
Use mock instead of mocker in the tests
Description of the change
Use mock (python-mock) instead of mocker (python-mocker) as there is no py3k package for the later.
To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'requirements.txt' | |||
2 | --- requirements.txt 2012-05-08 16:23:00 +0000 | |||
3 | +++ requirements.txt 2013-03-07 15:53:38 +0000 | |||
4 | @@ -1,7 +1,7 @@ | |||
5 | 1 | Twisted==11.1.0 | 1 | Twisted==11.1.0 |
6 | 2 | carbon==0.9.9 | 2 | carbon==0.9.9 |
7 | 3 | whisper==0.9.9 | 3 | whisper==0.9.9 |
9 | 4 | mocker==1.1 | 4 | mock==1.0 |
10 | 5 | psutil==0.4.1 | 5 | psutil==0.4.1 |
11 | 6 | wsgiref==0.1.2 | 6 | wsgiref==0.1.2 |
12 | 7 | zope.interface==3.8.0 | 7 | zope.interface==3.8.0 |
13 | 8 | 8 | ||
14 | === modified file 'txstatsd/tests/test_client.py' | |||
15 | --- txstatsd/tests/test_client.py 2012-12-27 20:49:06 +0000 | |||
16 | +++ txstatsd/tests/test_client.py 2013-03-07 15:53:38 +0000 | |||
17 | @@ -22,7 +22,7 @@ | |||
18 | 22 | 22 | ||
19 | 23 | import sys | 23 | import sys |
20 | 24 | 24 | ||
22 | 25 | from mocker import Mocker, expect, ANY | 25 | from mock import Mock, call |
23 | 26 | from twisted.internet import reactor | 26 | from twisted.internet import reactor |
24 | 27 | from twisted.internet.defer import inlineCallbacks, Deferred | 27 | from twisted.internet.defer import inlineCallbacks, Deferred |
25 | 28 | from twisted.python import log | 28 | from twisted.python import log |
26 | @@ -67,7 +67,6 @@ | |||
27 | 67 | super(TestClient, self).setUp() | 67 | super(TestClient, self).setUp() |
28 | 68 | self.client = None | 68 | self.client = None |
29 | 69 | self.exception = None | 69 | self.exception = None |
30 | 70 | self.mocker = Mocker() | ||
31 | 71 | 70 | ||
32 | 72 | def tearDown(self): | 71 | def tearDown(self): |
33 | 73 | if self.client: | 72 | if self.client: |
34 | @@ -250,11 +249,11 @@ | |||
35 | 250 | self.client = TwistedStatsDClient('localhost', 8000) | 249 | self.client = TwistedStatsDClient('localhost', 8000) |
36 | 251 | self.build_protocol() | 250 | self.build_protocol() |
37 | 252 | 251 | ||
40 | 253 | self.client.connect_callback = self.mocker.mock() | 252 | self.client.connect_callback = Mock() |
39 | 254 | expect(self.client.connect_callback()) | ||
41 | 255 | 253 | ||
44 | 256 | with self.mocker: | 254 | self.client.host_resolved('127.0.0.1') |
45 | 257 | self.client.host_resolved('127.0.0.1') | 255 | self.assertTrue(self.client.connect_callback.called) |
46 | 256 | self.client.connect_callback.assert_called_once_with() | ||
47 | 258 | 257 | ||
48 | 259 | def test_sends_messages_to_gateway_after_host_resolves(self): | 258 | def test_sends_messages_to_gateway_after_host_resolves(self): |
49 | 260 | """After the host is resolved, send messages to the | 259 | """After the host is resolved, send messages to the |
50 | @@ -265,14 +264,12 @@ | |||
51 | 265 | 264 | ||
52 | 266 | message = 'some data' | 265 | message = 'some data' |
53 | 267 | bytes_sent = len(message) | 266 | bytes_sent = len(message) |
62 | 268 | self.client.data_queue = self.mocker.mock(spec=DataQueue) # not called | 267 | self.client.data_queue = Mock(spec=DataQueue) |
63 | 269 | self.client.transport_gateway = self.mocker.mock(spec=TransportGateway) | 268 | self.client.transport_gateway = Mock(spec=TransportGateway) |
64 | 270 | callback = self.mocker.mock() | 269 | callback = Mock() |
65 | 271 | expect(self.client.transport_gateway.write(message, callback)).result( | 270 | self.client.transport_gateway.write.return_value = bytes_sent |
66 | 272 | bytes_sent) | 271 | self.assertEqual(self.client.write(message, callback), bytes_sent) |
67 | 273 | 272 | self.client.transport_gateway.write.assert_called_once_with(message, callback) | |
60 | 274 | with self.mocker: | ||
61 | 275 | self.assertEqual(self.client.write(message, callback), bytes_sent) | ||
68 | 276 | 273 | ||
69 | 277 | def test_sends_messages_to_queue_before_host_resolves(self): | 274 | def test_sends_messages_to_queue_before_host_resolves(self): |
70 | 278 | """Before the host is resolved, send messages to the DataQueue.""" | 275 | """Before the host is resolved, send messages to the DataQueue.""" |
71 | @@ -280,13 +277,12 @@ | |||
72 | 280 | self.build_protocol() | 277 | self.build_protocol() |
73 | 281 | 278 | ||
74 | 282 | message = 'some data' | 279 | message = 'some data' |
82 | 283 | bytes_sent = len(message) | 280 | self.client.data_queue = Mock(spec=DataQueue) |
83 | 284 | self.client.data_queue = self.mocker.mock(spec=DataQueue) | 281 | callback = Mock() |
84 | 285 | callback = self.mocker.mock() | 282 | self.client.data_queue.write.return_value = None |
85 | 286 | expect(self.client.data_queue.write(message, callback)).result(None) | 283 | result = self.client.write(message, callback) |
86 | 287 | 284 | self.client.data_queue.write.assert_called_once_with(message, callback) | |
87 | 288 | with self.mocker: | 285 | self.assertEqual(result, None) |
81 | 289 | self.assertEqual(self.client.write(message, callback), None) | ||
88 | 290 | 286 | ||
89 | 291 | def test_flushes_queued_messages_to_the_gateway_when_host_resolves(self): | 287 | def test_flushes_queued_messages_to_the_gateway_when_host_resolves(self): |
90 | 292 | """As soon as the host is resolved, flush all messages to the | 288 | """As soon as the host is resolved, flush all messages to the |
91 | @@ -298,14 +294,14 @@ | |||
92 | 298 | self.client.data_queue.write('data 2', 'callback 2') | 294 | self.client.data_queue.write('data 2', 'callback 2') |
93 | 299 | self.client.data_queue.write('data 3', 'callback 3') | 295 | self.client.data_queue.write('data 3', 'callback 3') |
94 | 300 | 296 | ||
96 | 301 | mock_gateway_write = self.mocker.mock() | 297 | mock_gateway_write = Mock() |
97 | 302 | self.patch(TransportGateway, 'write', mock_gateway_write) | 298 | self.patch(TransportGateway, 'write', mock_gateway_write) |
104 | 303 | expect(mock_gateway_write('data 1', 'callback 1')) | 299 | self.client.host_resolved('127.0.0.1') |
105 | 304 | expect(mock_gateway_write('data 2', 'callback 2')) | 300 | self.assertTrue(mock_gateway_write.call_count, 3) |
106 | 305 | expect(mock_gateway_write('data 3', 'callback 3')) | 301 | expected = [call('data 1', 'callback 1'), |
107 | 306 | 302 | call('data 2', 'callback 2'), | |
108 | 307 | with self.mocker: | 303 | call('data 3', 'callback 3')] |
109 | 308 | self.client.host_resolved('127.0.0.1') | 304 | self.assertEqual(mock_gateway_write.call_args_list, expected) |
110 | 309 | 305 | ||
111 | 310 | def test_sets_client_transport_when_connected(self): | 306 | def test_sets_client_transport_when_connected(self): |
112 | 311 | """Set the transport as an attribute of the client.""" | 307 | """Set the transport as an attribute of the client.""" |
113 | 312 | 308 | ||
114 | === modified file 'txstatsd/tests/test_process.py' | |||
115 | --- txstatsd/tests/test_process.py 2012-06-28 17:29:26 +0000 | |||
116 | +++ txstatsd/tests/test_process.py 2013-03-07 15:53:38 +0000 | |||
117 | @@ -23,7 +23,7 @@ | |||
118 | 23 | import psutil | 23 | import psutil |
119 | 24 | import sys | 24 | import sys |
120 | 25 | 25 | ||
122 | 26 | from mocker import MockerTestCase | 26 | import mock |
123 | 27 | from twisted.trial.unittest import TestCase | 27 | from twisted.trial.unittest import TestCase |
124 | 28 | 28 | ||
125 | 29 | from txstatsd.process import ( | 29 | from txstatsd.process import ( |
126 | @@ -82,7 +82,7 @@ | |||
127 | 82 | tun0: 5138313 24837 0 0 0 0 0 0 5226635 26986 0 0 0 0 0 0""" | 82 | tun0: 5138313 24837 0 0 0 0 0 0 5226635 26986 0 0 0 0 0 0""" |
128 | 83 | 83 | ||
129 | 84 | 84 | ||
131 | 85 | class TestSystemPerformance(TestCase, MockerTestCase): | 85 | class TestSystemPerformance(TestCase): |
132 | 86 | """Test system performance monitoring.""" | 86 | """Test system performance monitoring.""" |
133 | 87 | 87 | ||
134 | 88 | def test_loadinfo(self): | 88 | def test_loadinfo(self): |
135 | @@ -102,11 +102,10 @@ | |||
136 | 102 | def test_cpu_counters(self): | 102 | def test_cpu_counters(self): |
137 | 103 | """System cpu counters are collected through psutil.""" | 103 | """System cpu counters are collected through psutil.""" |
138 | 104 | cpu_times = psutil.cpu_times() | 104 | cpu_times = psutil.cpu_times() |
144 | 105 | mock = self.mocker.replace("psutil.cpu_times") | 105 | with mock.patch("psutil.cpu_times"): |
145 | 106 | self.expect(mock(percpu=False)).result(cpu_times) | 106 | psutil.cpu_times.return_value = cpu_times |
146 | 107 | self.mocker.replay() | 107 | result = report_system_stats() |
147 | 108 | 108 | psutil.cpu_times.assert_called_once_with(percpu=False) | |
143 | 109 | result = report_system_stats() | ||
148 | 110 | # cpu_times is platform-dependent | 109 | # cpu_times is platform-dependent |
149 | 111 | if sys.platform.lower().startswith("linux"): | 110 | if sys.platform.lower().startswith("linux"): |
150 | 112 | self.assertEqual(cpu_times.user, result["sys.cpu.user"]) | 111 | self.assertEqual(cpu_times.user, result["sys.cpu.user"]) |
151 | @@ -132,11 +131,10 @@ | |||
152 | 132 | def test_per_cpu_counters(self): | 131 | def test_per_cpu_counters(self): |
153 | 133 | """System percpu counters are collected through psutil.""" | 132 | """System percpu counters are collected through psutil.""" |
154 | 134 | cpu_times = psutil.cpu_times() | 133 | cpu_times = psutil.cpu_times() |
160 | 135 | mock = self.mocker.replace("psutil.cpu_times") | 134 | with mock.patch("psutil.cpu_times"): |
161 | 136 | self.expect(mock(percpu=True)).result([cpu_times, cpu_times]) | 135 | psutil.cpu_times.return_value = [cpu_times, cpu_times] |
162 | 137 | self.mocker.replay() | 136 | result = report_system_stats(percpu=True) |
163 | 138 | 137 | psutil.cpu_times.assert_called_once_with(percpu=True) | |
159 | 139 | result = report_system_stats(percpu=True) | ||
164 | 140 | # cpu_times is platform-dependent | 138 | # cpu_times is platform-dependent |
165 | 141 | if sys.platform.lower().startswith("linux"): | 139 | if sys.platform.lower().startswith("linux"): |
166 | 142 | self.assertEqual(cpu_times.user, result["sys.cpu.000.user"]) | 140 | self.assertEqual(cpu_times.user, result["sys.cpu.000.user"]) |
167 | @@ -187,14 +185,12 @@ | |||
168 | 187 | cpu_percent = process.get_cpu_percent() | 185 | cpu_percent = process.get_cpu_percent() |
169 | 188 | memory_percent = process.get_memory_percent() | 186 | memory_percent = process.get_memory_percent() |
170 | 189 | 187 | ||
179 | 190 | mock = self.mocker.mock() | 188 | proc = mock.Mock() |
180 | 191 | self.expect(mock.get_memory_info()).result((vsize, rss)) | 189 | proc.get_memory_info.return_value = (vsize, rss) |
181 | 192 | self.expect(mock.get_cpu_percent()).result(cpu_percent) | 190 | proc.get_cpu_percent.return_value = cpu_percent |
182 | 193 | self.expect(mock.get_memory_percent()).result(memory_percent) | 191 | proc.get_memory_percent.return_value = memory_percent |
183 | 194 | self.expect(mock.get_num_threads).result(None) | 192 | proc.get_num_threads = None |
184 | 195 | self.mocker.replay() | 193 | result = ProcessReport(process=proc).get_memory_and_cpu() |
177 | 196 | |||
178 | 197 | result = ProcessReport(process=mock).get_memory_and_cpu() | ||
185 | 198 | self.assertEqual(cpu_percent, result["proc.cpu.percent"]) | 194 | self.assertEqual(cpu_percent, result["proc.cpu.percent"]) |
186 | 199 | self.assertEqual(vsize, result["proc.memory.vsize"]) | 195 | self.assertEqual(vsize, result["proc.memory.vsize"]) |
187 | 200 | self.assertEqual(rss, result["proc.memory.rss"]) | 196 | self.assertEqual(rss, result["proc.memory.rss"]) |
188 | @@ -208,11 +204,10 @@ | |||
189 | 208 | process = psutil.Process(os.getpid()) | 204 | process = psutil.Process(os.getpid()) |
190 | 209 | utime, stime = process.get_cpu_times() | 205 | utime, stime = process.get_cpu_times() |
191 | 210 | 206 | ||
197 | 211 | mock = self.mocker.mock() | 207 | proc = mock.Mock() |
198 | 212 | self.expect(mock.get_cpu_times()).result((utime, stime)) | 208 | proc.get_cpu_times.return_value = (utime, stime) |
199 | 213 | self.mocker.replay() | 209 | result = ProcessReport(process=proc).get_cpu_counters() |
200 | 214 | 210 | proc.get_cpu_times.assert_called_once_with() | |
196 | 215 | result = ProcessReport(process=mock).get_cpu_counters() | ||
201 | 216 | self.assertEqual(utime, result["proc.cpu.user"]) | 211 | self.assertEqual(utime, result["proc.cpu.user"]) |
202 | 217 | self.assertEqual(stime, result["proc.cpu.system"]) | 212 | self.assertEqual(stime, result["proc.cpu.system"]) |
203 | 218 | 213 | ||
204 | @@ -229,14 +224,18 @@ | |||
205 | 229 | cpu_percent = process.get_cpu_percent() | 224 | cpu_percent = process.get_cpu_percent() |
206 | 230 | memory_percent = process.get_memory_percent() | 225 | memory_percent = process.get_memory_percent() |
207 | 231 | 226 | ||
216 | 232 | mock = self.mocker.mock() | 227 | proc = mock.Mock() |
217 | 233 | self.expect(mock.get_memory_info()).result((vsize, rss)) | 228 | proc.get_memory_info.return_value = (vsize, rss) |
218 | 234 | self.expect(mock.get_cpu_percent()).result(cpu_percent) | 229 | proc.get_cpu_percent.return_value = cpu_percent |
219 | 235 | self.expect(mock.get_memory_percent()).result(memory_percent) | 230 | proc.get_memory_percent.return_value = memory_percent |
220 | 236 | self.expect(mock.get_num_threads()).result(1) | 231 | proc.get_num_threads.return_value = 1 |
221 | 237 | self.mocker.replay() | 232 | result = ProcessReport(process=proc).get_memory_and_cpu() |
222 | 238 | 233 | proc.get_memory_info.assert_called_once_with() | |
223 | 239 | result = ProcessReport(process=mock).get_memory_and_cpu() | 234 | proc.get_cpu_percent.assert_called_once_with() |
224 | 235 | proc.get_memory_percent.assert_called_once_with() | ||
225 | 236 | proc.get_num_threads.assert_called_once_with() | ||
226 | 237 | |||
227 | 238 | |||
228 | 240 | self.assertEqual(cpu_percent, result["proc.cpu.percent"]) | 239 | self.assertEqual(cpu_percent, result["proc.cpu.percent"]) |
229 | 241 | self.assertEqual(vsize, result["proc.memory.vsize"]) | 240 | self.assertEqual(vsize, result["proc.memory.vsize"]) |
230 | 242 | self.assertEqual(rss, result["proc.memory.rss"]) | 241 | self.assertEqual(rss, result["proc.memory.rss"]) |
231 | @@ -245,13 +244,11 @@ | |||
232 | 245 | 244 | ||
233 | 246 | def test_ioinfo(self): | 245 | def test_ioinfo(self): |
234 | 247 | """Process IO info is collected through psutil.""" | 246 | """Process IO info is collected through psutil.""" |
235 | 248 | mock = self.mocker.mock() | ||
236 | 249 | self.expect(mock.get_io_counters).result(None) | ||
237 | 250 | self.mocker.replay() | ||
238 | 251 | |||
239 | 252 | # If the version of psutil doesn't have the C{get_io_counters}, | 247 | # If the version of psutil doesn't have the C{get_io_counters}, |
240 | 253 | # then io stats are not included in the output. | 248 | # then io stats are not included in the output. |
242 | 254 | result = ProcessReport(process=mock).get_io_counters() | 249 | proc = mock.Mock() |
243 | 250 | proc.get_io_counters = None | ||
244 | 251 | result = ProcessReport(process=proc).get_io_counters() | ||
245 | 255 | self.failIf("proc.io.read.count" in result) | 252 | self.failIf("proc.io.read.count" in result) |
246 | 256 | self.failIf("proc.io.write.count" in result) | 253 | self.failIf("proc.io.write.count" in result) |
247 | 257 | self.failIf("proc.io.read.bytes" in result) | 254 | self.failIf("proc.io.read.bytes" in result) |
248 | @@ -266,12 +263,10 @@ | |||
249 | 266 | """ | 263 | """ |
250 | 267 | io_counters = (10, 42, 125, 16) | 264 | io_counters = (10, 42, 125, 16) |
251 | 268 | 265 | ||
258 | 269 | mock = self.mocker.mock() | 266 | proc = mock.Mock() |
259 | 270 | self.expect(mock.get_io_counters).result(mock) | 267 | proc.get_io_counters.return_value = io_counters |
260 | 271 | self.expect(mock.get_io_counters()).result(io_counters) | 268 | result = ProcessReport(process=proc).get_io_counters() |
261 | 272 | self.mocker.replay() | 269 | proc.get_io_counters.assert_called_once_with() |
256 | 273 | |||
257 | 274 | result = ProcessReport(process=mock).get_io_counters() | ||
262 | 275 | self.assertEqual(10, result["proc.io.read.count"]) | 270 | self.assertEqual(10, result["proc.io.read.count"]) |
263 | 276 | self.assertEqual(42, result["proc.io.write.count"]) | 271 | self.assertEqual(42, result["proc.io.write.count"]) |
264 | 277 | self.assertEqual(125, result["proc.io.read.bytes"]) | 272 | self.assertEqual(125, result["proc.io.read.bytes"]) |
265 | @@ -284,13 +279,11 @@ | |||
266 | 284 | If the version of psutil doesn't implement C{get_connections} for | 279 | If the version of psutil doesn't implement C{get_connections} for |
267 | 285 | L{Process}, then no information is returned. | 280 | L{Process}, then no information is returned. |
268 | 286 | """ | 281 | """ |
269 | 287 | mock = self.mocker.mock() | ||
270 | 288 | self.expect(mock.get_connections).result(None) | ||
271 | 289 | self.mocker.replay() | ||
272 | 290 | |||
273 | 291 | # If the version of psutil doesn't have the C{get_io_counters}, | 282 | # If the version of psutil doesn't have the C{get_io_counters}, |
274 | 292 | # then io stats are not included in the output. | 283 | # then io stats are not included in the output. |
276 | 293 | result = ProcessReport(process=mock).get_net_stats() | 284 | proc = mock.Mock() |
277 | 285 | proc.get_connections = None | ||
278 | 286 | result = ProcessReport(process=proc).get_net_stats() | ||
279 | 294 | self.failIf("proc.net.status.established" in result) | 287 | self.failIf("proc.net.status.established" in result) |
280 | 295 | 288 | ||
281 | 296 | def test_netinfo_with_get_connections(self): | 289 | def test_netinfo_with_get_connections(self): |
282 | @@ -311,37 +304,32 @@ | |||
283 | 311 | ("72.14.234.83", 443), "SYN_SENT") | 304 | ("72.14.234.83", 443), "SYN_SENT") |
284 | 312 | ] | 305 | ] |
285 | 313 | 306 | ||
292 | 314 | mock = self.mocker.mock() | 307 | proc = mock.Mock() |
293 | 315 | self.expect(mock.get_connections).result(mock) | 308 | proc.get_connections.return_value = connections |
294 | 316 | self.expect(mock.get_connections()).result(connections) | 309 | result = ProcessReport(process=proc).get_net_stats() |
295 | 317 | self.mocker.replay() | 310 | proc.get_connections.assert_called_once_with() |
290 | 318 | |||
291 | 319 | result = ProcessReport(process=mock).get_net_stats() | ||
296 | 320 | self.assertEqual(2, result["proc.net.status.established"]) | 311 | self.assertEqual(2, result["proc.net.status.established"]) |
297 | 321 | self.assertEqual(1, result["proc.net.status.closing"]) | 312 | self.assertEqual(1, result["proc.net.status.closing"]) |
298 | 322 | self.assertEqual(1, result["proc.net.status.syn_sent"]) | 313 | self.assertEqual(1, result["proc.net.status.syn_sent"]) |
299 | 323 | 314 | ||
300 | 324 | def test_reactor_stats(self): | 315 | def test_reactor_stats(self): |
301 | 325 | """Given a twisted reactor, pull out some stats from it.""" | 316 | """Given a twisted reactor, pull out some stats from it.""" |
308 | 326 | mock = self.mocker.mock() | 317 | mock_reactor = mock.Mock() |
309 | 327 | self.expect(mock.getReaders()).result([None, None, None]) | 318 | mock_reactor.getReaders.return_value = [None, None, None] |
310 | 328 | self.expect(mock.getWriters()).result([None, None]) | 319 | mock_reactor.getWriters.return_value = [None, None] |
311 | 329 | self.mocker.replay() | 320 | result = report_reactor_stats(mock_reactor)() |
306 | 330 | |||
307 | 331 | result = report_reactor_stats(mock)() | ||
312 | 332 | self.assertEqual(3, result["reactor.readers"]) | 321 | self.assertEqual(3, result["reactor.readers"]) |
313 | 333 | self.assertEqual(2, result["reactor.writers"]) | 322 | self.assertEqual(2, result["reactor.writers"]) |
314 | 334 | 323 | ||
315 | 335 | def test_threadpool_stats(self): | 324 | def test_threadpool_stats(self): |
316 | 336 | """Given a twisted threadpool, pull out some stats from it.""" | 325 | """Given a twisted threadpool, pull out some stats from it.""" |
323 | 337 | mock = self.mocker.mock() | 326 | mock_reactor = mock.Mock() |
324 | 338 | self.expect(mock.q.qsize()).result(42) | 327 | mock_reactor.q.qsize.return_value = 42 |
325 | 339 | self.expect(mock.threads).result(6 * [None]) | 328 | mock_reactor.threads = 6 * [None] |
326 | 340 | self.expect(mock.waiters).result(2 * [None]) | 329 | mock_reactor.waiters = 2 * [None] |
327 | 341 | self.expect(mock.working).result(4 * [None]) | 330 | mock_reactor.working = 4 * [None] |
322 | 342 | self.mocker.replay() | ||
328 | 343 | 331 | ||
330 | 344 | result = report_threadpool_stats(mock)() | 332 | result = report_threadpool_stats(mock_reactor)() |
331 | 345 | self.assertEqual(42, result["threadpool.queue"]) | 333 | self.assertEqual(42, result["threadpool.queue"]) |
332 | 346 | self.assertEqual(6, result["threadpool.threads"]) | 334 | self.assertEqual(6, result["threadpool.threads"]) |
333 | 347 | self.assertEqual(2, result["threadpool.waiters"]) | 335 | self.assertEqual(2, result["threadpool.waiters"]) |
334 | @@ -385,5 +373,5 @@ | |||
335 | 385 | self.assertEqual({"foo": 4}, wrapped()) | 373 | self.assertEqual({"foo": 4}, wrapped()) |
336 | 386 | self.assertEqual({"foo": 5}, wrapped()) | 374 | self.assertEqual({"foo": 5}, wrapped()) |
337 | 387 | self.assertEqual({"foo": 7}, wrapped()) | 375 | self.assertEqual({"foo": 7}, wrapped()) |
339 | 388 | 376 | ||
340 | 389 | 377 |