1 | n/a | import timeit |
---|
2 | n/a | import unittest |
---|
3 | n/a | import sys |
---|
4 | n/a | import io |
---|
5 | n/a | from textwrap import dedent |
---|
6 | n/a | |
---|
7 | n/a | from test.support import captured_stdout |
---|
8 | n/a | from test.support import captured_stderr |
---|
9 | n/a | |
---|
10 | n/a | # timeit's default number of iterations. |
---|
11 | n/a | DEFAULT_NUMBER = 1000000 |
---|
12 | n/a | |
---|
13 | n/a | # timeit's default number of repetitions. |
---|
14 | n/a | DEFAULT_REPEAT = 5 |
---|
15 | n/a | |
---|
16 | n/a | # XXX: some tests are commented out that would improve the coverage but take a |
---|
17 | n/a | # long time to run because they test the default number of loops, which is |
---|
18 | n/a | # large. The tests could be enabled if there was a way to override the default |
---|
19 | n/a | # number of loops during testing, but this would require changing the signature |
---|
20 | n/a | # of some functions that use the default as a default argument. |
---|
21 | n/a | |
---|
22 | n/a | class FakeTimer: |
---|
23 | n/a | BASE_TIME = 42.0 |
---|
24 | n/a | def __init__(self, seconds_per_increment=1.0): |
---|
25 | n/a | self.count = 0 |
---|
26 | n/a | self.setup_calls = 0 |
---|
27 | n/a | self.seconds_per_increment=seconds_per_increment |
---|
28 | n/a | timeit._fake_timer = self |
---|
29 | n/a | |
---|
30 | n/a | def __call__(self): |
---|
31 | n/a | return self.BASE_TIME + self.count * self.seconds_per_increment |
---|
32 | n/a | |
---|
33 | n/a | def inc(self): |
---|
34 | n/a | self.count += 1 |
---|
35 | n/a | |
---|
36 | n/a | def setup(self): |
---|
37 | n/a | self.setup_calls += 1 |
---|
38 | n/a | |
---|
39 | n/a | def wrap_timer(self, timer): |
---|
40 | n/a | """Records 'timer' and returns self as callable timer.""" |
---|
41 | n/a | self.saved_timer = timer |
---|
42 | n/a | return self |
---|
43 | n/a | |
---|
44 | n/a | class TestTimeit(unittest.TestCase): |
---|
45 | n/a | |
---|
46 | n/a | def tearDown(self): |
---|
47 | n/a | try: |
---|
48 | n/a | del timeit._fake_timer |
---|
49 | n/a | except AttributeError: |
---|
50 | n/a | pass |
---|
51 | n/a | |
---|
52 | n/a | def test_reindent_empty(self): |
---|
53 | n/a | self.assertEqual(timeit.reindent("", 0), "") |
---|
54 | n/a | self.assertEqual(timeit.reindent("", 4), "") |
---|
55 | n/a | |
---|
56 | n/a | def test_reindent_single(self): |
---|
57 | n/a | self.assertEqual(timeit.reindent("pass", 0), "pass") |
---|
58 | n/a | self.assertEqual(timeit.reindent("pass", 4), "pass") |
---|
59 | n/a | |
---|
60 | n/a | def test_reindent_multi_empty(self): |
---|
61 | n/a | self.assertEqual(timeit.reindent("\n\n", 0), "\n\n") |
---|
62 | n/a | self.assertEqual(timeit.reindent("\n\n", 4), "\n \n ") |
---|
63 | n/a | |
---|
64 | n/a | def test_reindent_multi(self): |
---|
65 | n/a | self.assertEqual(timeit.reindent( |
---|
66 | n/a | "print()\npass\nbreak", 0), |
---|
67 | n/a | "print()\npass\nbreak") |
---|
68 | n/a | self.assertEqual(timeit.reindent( |
---|
69 | n/a | "print()\npass\nbreak", 4), |
---|
70 | n/a | "print()\n pass\n break") |
---|
71 | n/a | |
---|
72 | n/a | def test_timer_invalid_stmt(self): |
---|
73 | n/a | self.assertRaises(ValueError, timeit.Timer, stmt=None) |
---|
74 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='return') |
---|
75 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='yield') |
---|
76 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='yield from ()') |
---|
77 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='break') |
---|
78 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='continue') |
---|
79 | n/a | self.assertRaises(SyntaxError, timeit.Timer, stmt='from timeit import *') |
---|
80 | n/a | |
---|
81 | n/a | def test_timer_invalid_setup(self): |
---|
82 | n/a | self.assertRaises(ValueError, timeit.Timer, setup=None) |
---|
83 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='return') |
---|
84 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='yield') |
---|
85 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='yield from ()') |
---|
86 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='break') |
---|
87 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='continue') |
---|
88 | n/a | self.assertRaises(SyntaxError, timeit.Timer, setup='from timeit import *') |
---|
89 | n/a | |
---|
90 | n/a | fake_setup = "import timeit\ntimeit._fake_timer.setup()" |
---|
91 | n/a | fake_stmt = "import timeit\ntimeit._fake_timer.inc()" |
---|
92 | n/a | |
---|
93 | n/a | def fake_callable_setup(self): |
---|
94 | n/a | self.fake_timer.setup() |
---|
95 | n/a | |
---|
96 | n/a | def fake_callable_stmt(self): |
---|
97 | n/a | self.fake_timer.inc() |
---|
98 | n/a | |
---|
99 | n/a | def timeit(self, stmt, setup, number=None, globals=None): |
---|
100 | n/a | self.fake_timer = FakeTimer() |
---|
101 | n/a | t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer, |
---|
102 | n/a | globals=globals) |
---|
103 | n/a | kwargs = {} |
---|
104 | n/a | if number is None: |
---|
105 | n/a | number = DEFAULT_NUMBER |
---|
106 | n/a | else: |
---|
107 | n/a | kwargs['number'] = number |
---|
108 | n/a | delta_time = t.timeit(**kwargs) |
---|
109 | n/a | self.assertEqual(self.fake_timer.setup_calls, 1) |
---|
110 | n/a | self.assertEqual(self.fake_timer.count, number) |
---|
111 | n/a | self.assertEqual(delta_time, number) |
---|
112 | n/a | |
---|
113 | n/a | # Takes too long to run in debug build. |
---|
114 | n/a | #def test_timeit_default_iters(self): |
---|
115 | n/a | # self.timeit(self.fake_stmt, self.fake_setup) |
---|
116 | n/a | |
---|
117 | n/a | def test_timeit_zero_iters(self): |
---|
118 | n/a | self.timeit(self.fake_stmt, self.fake_setup, number=0) |
---|
119 | n/a | |
---|
120 | n/a | def test_timeit_few_iters(self): |
---|
121 | n/a | self.timeit(self.fake_stmt, self.fake_setup, number=3) |
---|
122 | n/a | |
---|
123 | n/a | def test_timeit_callable_stmt(self): |
---|
124 | n/a | self.timeit(self.fake_callable_stmt, self.fake_setup, number=3) |
---|
125 | n/a | |
---|
126 | n/a | def test_timeit_callable_setup(self): |
---|
127 | n/a | self.timeit(self.fake_stmt, self.fake_callable_setup, number=3) |
---|
128 | n/a | |
---|
129 | n/a | def test_timeit_callable_stmt_and_setup(self): |
---|
130 | n/a | self.timeit(self.fake_callable_stmt, |
---|
131 | n/a | self.fake_callable_setup, number=3) |
---|
132 | n/a | |
---|
133 | n/a | # Takes too long to run in debug build. |
---|
134 | n/a | #def test_timeit_function(self): |
---|
135 | n/a | # delta_time = timeit.timeit(self.fake_stmt, self.fake_setup, |
---|
136 | n/a | # timer=FakeTimer()) |
---|
137 | n/a | # self.assertEqual(delta_time, DEFAULT_NUMBER) |
---|
138 | n/a | |
---|
139 | n/a | def test_timeit_function_zero_iters(self): |
---|
140 | n/a | delta_time = timeit.timeit(self.fake_stmt, self.fake_setup, number=0, |
---|
141 | n/a | timer=FakeTimer()) |
---|
142 | n/a | self.assertEqual(delta_time, 0) |
---|
143 | n/a | |
---|
144 | n/a | def test_timeit_globals_args(self): |
---|
145 | n/a | global _global_timer |
---|
146 | n/a | _global_timer = FakeTimer() |
---|
147 | n/a | t = timeit.Timer(stmt='_global_timer.inc()', timer=_global_timer) |
---|
148 | n/a | self.assertRaises(NameError, t.timeit, number=3) |
---|
149 | n/a | timeit.timeit(stmt='_global_timer.inc()', timer=_global_timer, |
---|
150 | n/a | globals=globals(), number=3) |
---|
151 | n/a | local_timer = FakeTimer() |
---|
152 | n/a | timeit.timeit(stmt='local_timer.inc()', timer=local_timer, |
---|
153 | n/a | globals=locals(), number=3) |
---|
154 | n/a | |
---|
155 | n/a | def repeat(self, stmt, setup, repeat=None, number=None): |
---|
156 | n/a | self.fake_timer = FakeTimer() |
---|
157 | n/a | t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer) |
---|
158 | n/a | kwargs = {} |
---|
159 | n/a | if repeat is None: |
---|
160 | n/a | repeat = DEFAULT_REPEAT |
---|
161 | n/a | else: |
---|
162 | n/a | kwargs['repeat'] = repeat |
---|
163 | n/a | if number is None: |
---|
164 | n/a | number = DEFAULT_NUMBER |
---|
165 | n/a | else: |
---|
166 | n/a | kwargs['number'] = number |
---|
167 | n/a | delta_times = t.repeat(**kwargs) |
---|
168 | n/a | self.assertEqual(self.fake_timer.setup_calls, repeat) |
---|
169 | n/a | self.assertEqual(self.fake_timer.count, repeat * number) |
---|
170 | n/a | self.assertEqual(delta_times, repeat * [float(number)]) |
---|
171 | n/a | |
---|
172 | n/a | # Takes too long to run in debug build. |
---|
173 | n/a | #def test_repeat_default(self): |
---|
174 | n/a | # self.repeat(self.fake_stmt, self.fake_setup) |
---|
175 | n/a | |
---|
176 | n/a | def test_repeat_zero_reps(self): |
---|
177 | n/a | self.repeat(self.fake_stmt, self.fake_setup, repeat=0) |
---|
178 | n/a | |
---|
179 | n/a | def test_repeat_zero_iters(self): |
---|
180 | n/a | self.repeat(self.fake_stmt, self.fake_setup, number=0) |
---|
181 | n/a | |
---|
182 | n/a | def test_repeat_few_reps_and_iters(self): |
---|
183 | n/a | self.repeat(self.fake_stmt, self.fake_setup, repeat=3, number=5) |
---|
184 | n/a | |
---|
185 | n/a | def test_repeat_callable_stmt(self): |
---|
186 | n/a | self.repeat(self.fake_callable_stmt, self.fake_setup, |
---|
187 | n/a | repeat=3, number=5) |
---|
188 | n/a | |
---|
189 | n/a | def test_repeat_callable_setup(self): |
---|
190 | n/a | self.repeat(self.fake_stmt, self.fake_callable_setup, |
---|
191 | n/a | repeat=3, number=5) |
---|
192 | n/a | |
---|
193 | n/a | def test_repeat_callable_stmt_and_setup(self): |
---|
194 | n/a | self.repeat(self.fake_callable_stmt, self.fake_callable_setup, |
---|
195 | n/a | repeat=3, number=5) |
---|
196 | n/a | |
---|
197 | n/a | # Takes too long to run in debug build. |
---|
198 | n/a | #def test_repeat_function(self): |
---|
199 | n/a | # delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, |
---|
200 | n/a | # timer=FakeTimer()) |
---|
201 | n/a | # self.assertEqual(delta_times, DEFAULT_REPEAT * [float(DEFAULT_NUMBER)]) |
---|
202 | n/a | |
---|
203 | n/a | def test_repeat_function_zero_reps(self): |
---|
204 | n/a | delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, repeat=0, |
---|
205 | n/a | timer=FakeTimer()) |
---|
206 | n/a | self.assertEqual(delta_times, []) |
---|
207 | n/a | |
---|
208 | n/a | def test_repeat_function_zero_iters(self): |
---|
209 | n/a | delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, number=0, |
---|
210 | n/a | timer=FakeTimer()) |
---|
211 | n/a | self.assertEqual(delta_times, DEFAULT_REPEAT * [0.0]) |
---|
212 | n/a | |
---|
213 | n/a | def assert_exc_string(self, exc_string, expected_exc_name): |
---|
214 | n/a | exc_lines = exc_string.splitlines() |
---|
215 | n/a | self.assertGreater(len(exc_lines), 2) |
---|
216 | n/a | self.assertTrue(exc_lines[0].startswith('Traceback')) |
---|
217 | n/a | self.assertTrue(exc_lines[-1].startswith(expected_exc_name)) |
---|
218 | n/a | |
---|
219 | n/a | def test_print_exc(self): |
---|
220 | n/a | s = io.StringIO() |
---|
221 | n/a | t = timeit.Timer("1/0") |
---|
222 | n/a | try: |
---|
223 | n/a | t.timeit() |
---|
224 | n/a | except: |
---|
225 | n/a | t.print_exc(s) |
---|
226 | n/a | self.assert_exc_string(s.getvalue(), 'ZeroDivisionError') |
---|
227 | n/a | |
---|
228 | n/a | MAIN_DEFAULT_OUTPUT = "1 loop, best of 5: 1 sec per loop\n" |
---|
229 | n/a | |
---|
230 | n/a | def run_main(self, seconds_per_increment=1.0, switches=None, timer=None): |
---|
231 | n/a | if timer is None: |
---|
232 | n/a | timer = FakeTimer(seconds_per_increment=seconds_per_increment) |
---|
233 | n/a | if switches is None: |
---|
234 | n/a | args = [] |
---|
235 | n/a | else: |
---|
236 | n/a | args = switches[:] |
---|
237 | n/a | args.append(self.fake_stmt) |
---|
238 | n/a | # timeit.main() modifies sys.path, so save and restore it. |
---|
239 | n/a | orig_sys_path = sys.path[:] |
---|
240 | n/a | with captured_stdout() as s: |
---|
241 | n/a | timeit.main(args=args, _wrap_timer=timer.wrap_timer) |
---|
242 | n/a | sys.path[:] = orig_sys_path[:] |
---|
243 | n/a | return s.getvalue() |
---|
244 | n/a | |
---|
245 | n/a | def test_main_bad_switch(self): |
---|
246 | n/a | s = self.run_main(switches=['--bad-switch']) |
---|
247 | n/a | self.assertEqual(s, dedent("""\ |
---|
248 | n/a | option --bad-switch not recognized |
---|
249 | n/a | use -h/--help for command line help |
---|
250 | n/a | """)) |
---|
251 | n/a | |
---|
252 | n/a | def test_main_seconds(self): |
---|
253 | n/a | s = self.run_main(seconds_per_increment=5.5) |
---|
254 | n/a | self.assertEqual(s, "1 loop, best of 5: 5.5 sec per loop\n") |
---|
255 | n/a | |
---|
256 | n/a | def test_main_milliseconds(self): |
---|
257 | n/a | s = self.run_main(seconds_per_increment=0.0055) |
---|
258 | n/a | self.assertEqual(s, "50 loops, best of 5: 5.5 msec per loop\n") |
---|
259 | n/a | |
---|
260 | n/a | def test_main_microseconds(self): |
---|
261 | n/a | s = self.run_main(seconds_per_increment=0.0000025, switches=['-n100']) |
---|
262 | n/a | self.assertEqual(s, "100 loops, best of 5: 2.5 usec per loop\n") |
---|
263 | n/a | |
---|
264 | n/a | def test_main_fixed_iters(self): |
---|
265 | n/a | s = self.run_main(seconds_per_increment=2.0, switches=['-n35']) |
---|
266 | n/a | self.assertEqual(s, "35 loops, best of 5: 2 sec per loop\n") |
---|
267 | n/a | |
---|
268 | n/a | def test_main_setup(self): |
---|
269 | n/a | s = self.run_main(seconds_per_increment=2.0, |
---|
270 | n/a | switches=['-n35', '-s', 'print("CustomSetup")']) |
---|
271 | n/a | self.assertEqual(s, "CustomSetup\n" * DEFAULT_REPEAT + |
---|
272 | n/a | "35 loops, best of 5: 2 sec per loop\n") |
---|
273 | n/a | |
---|
274 | n/a | def test_main_multiple_setups(self): |
---|
275 | n/a | s = self.run_main(seconds_per_increment=2.0, |
---|
276 | n/a | switches=['-n35', '-s', 'a = "CustomSetup"', '-s', 'print(a)']) |
---|
277 | n/a | self.assertEqual(s, "CustomSetup\n" * DEFAULT_REPEAT + |
---|
278 | n/a | "35 loops, best of 5: 2 sec per loop\n") |
---|
279 | n/a | |
---|
280 | n/a | def test_main_fixed_reps(self): |
---|
281 | n/a | s = self.run_main(seconds_per_increment=60.0, switches=['-r9']) |
---|
282 | n/a | self.assertEqual(s, "1 loop, best of 9: 60 sec per loop\n") |
---|
283 | n/a | |
---|
284 | n/a | def test_main_negative_reps(self): |
---|
285 | n/a | s = self.run_main(seconds_per_increment=60.0, switches=['-r-5']) |
---|
286 | n/a | self.assertEqual(s, "1 loop, best of 1: 60 sec per loop\n") |
---|
287 | n/a | |
---|
288 | n/a | @unittest.skipIf(sys.flags.optimize >= 2, "need __doc__") |
---|
289 | n/a | def test_main_help(self): |
---|
290 | n/a | s = self.run_main(switches=['-h']) |
---|
291 | n/a | # Note: It's not clear that the trailing space was intended as part of |
---|
292 | n/a | # the help text, but since it's there, check for it. |
---|
293 | n/a | self.assertEqual(s, timeit.__doc__ + ' ') |
---|
294 | n/a | |
---|
295 | n/a | def test_main_verbose(self): |
---|
296 | n/a | s = self.run_main(switches=['-v']) |
---|
297 | n/a | self.assertEqual(s, dedent("""\ |
---|
298 | n/a | 1 loop -> 1 secs |
---|
299 | n/a | |
---|
300 | n/a | raw times: 1 sec, 1 sec, 1 sec, 1 sec, 1 sec |
---|
301 | n/a | |
---|
302 | n/a | 1 loop, best of 5: 1 sec per loop |
---|
303 | n/a | """)) |
---|
304 | n/a | |
---|
305 | n/a | def test_main_very_verbose(self): |
---|
306 | n/a | s = self.run_main(seconds_per_increment=0.000_030, switches=['-vv']) |
---|
307 | n/a | self.assertEqual(s, dedent("""\ |
---|
308 | n/a | 1 loop -> 3e-05 secs |
---|
309 | n/a | 2 loops -> 6e-05 secs |
---|
310 | n/a | 5 loops -> 0.00015 secs |
---|
311 | n/a | 10 loops -> 0.0003 secs |
---|
312 | n/a | 20 loops -> 0.0006 secs |
---|
313 | n/a | 50 loops -> 0.0015 secs |
---|
314 | n/a | 100 loops -> 0.003 secs |
---|
315 | n/a | 200 loops -> 0.006 secs |
---|
316 | n/a | 500 loops -> 0.015 secs |
---|
317 | n/a | 1000 loops -> 0.03 secs |
---|
318 | n/a | 2000 loops -> 0.06 secs |
---|
319 | n/a | 5000 loops -> 0.15 secs |
---|
320 | n/a | 10000 loops -> 0.3 secs |
---|
321 | n/a | |
---|
322 | n/a | raw times: 300 msec, 300 msec, 300 msec, 300 msec, 300 msec |
---|
323 | n/a | |
---|
324 | n/a | 10000 loops, best of 5: 30 usec per loop |
---|
325 | n/a | """)) |
---|
326 | n/a | |
---|
327 | n/a | def test_main_with_time_unit(self): |
---|
328 | n/a | unit_sec = self.run_main(seconds_per_increment=0.003, |
---|
329 | n/a | switches=['-u', 'sec']) |
---|
330 | n/a | self.assertEqual(unit_sec, |
---|
331 | n/a | "100 loops, best of 5: 0.003 sec per loop\n") |
---|
332 | n/a | unit_msec = self.run_main(seconds_per_increment=0.003, |
---|
333 | n/a | switches=['-u', 'msec']) |
---|
334 | n/a | self.assertEqual(unit_msec, |
---|
335 | n/a | "100 loops, best of 5: 3 msec per loop\n") |
---|
336 | n/a | unit_usec = self.run_main(seconds_per_increment=0.003, |
---|
337 | n/a | switches=['-u', 'usec']) |
---|
338 | n/a | self.assertEqual(unit_usec, |
---|
339 | n/a | "100 loops, best of 5: 3e+03 usec per loop\n") |
---|
340 | n/a | # Test invalid unit input |
---|
341 | n/a | with captured_stderr() as error_stringio: |
---|
342 | n/a | invalid = self.run_main(seconds_per_increment=0.003, |
---|
343 | n/a | switches=['-u', 'parsec']) |
---|
344 | n/a | self.assertEqual(error_stringio.getvalue(), |
---|
345 | n/a | "Unrecognized unit. Please select nsec, usec, msec, or sec.\n") |
---|
346 | n/a | |
---|
347 | n/a | def test_main_exception(self): |
---|
348 | n/a | with captured_stderr() as error_stringio: |
---|
349 | n/a | s = self.run_main(switches=['1/0']) |
---|
350 | n/a | self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError') |
---|
351 | n/a | |
---|
352 | n/a | def test_main_exception_fixed_reps(self): |
---|
353 | n/a | with captured_stderr() as error_stringio: |
---|
354 | n/a | s = self.run_main(switches=['-n1', '1/0']) |
---|
355 | n/a | self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError') |
---|
356 | n/a | |
---|
357 | n/a | def autorange(self, seconds_per_increment=1/1024, callback=None): |
---|
358 | n/a | timer = FakeTimer(seconds_per_increment=seconds_per_increment) |
---|
359 | n/a | t = timeit.Timer(stmt=self.fake_stmt, setup=self.fake_setup, timer=timer) |
---|
360 | n/a | return t.autorange(callback) |
---|
361 | n/a | |
---|
362 | n/a | def test_autorange(self): |
---|
363 | n/a | num_loops, time_taken = self.autorange() |
---|
364 | n/a | self.assertEqual(num_loops, 500) |
---|
365 | n/a | self.assertEqual(time_taken, 500/1024) |
---|
366 | n/a | |
---|
367 | n/a | def test_autorange_second(self): |
---|
368 | n/a | num_loops, time_taken = self.autorange(seconds_per_increment=1.0) |
---|
369 | n/a | self.assertEqual(num_loops, 1) |
---|
370 | n/a | self.assertEqual(time_taken, 1.0) |
---|
371 | n/a | |
---|
372 | n/a | def test_autorange_with_callback(self): |
---|
373 | n/a | def callback(a, b): |
---|
374 | n/a | print("{} {:.3f}".format(a, b)) |
---|
375 | n/a | with captured_stdout() as s: |
---|
376 | n/a | num_loops, time_taken = self.autorange(callback=callback) |
---|
377 | n/a | self.assertEqual(num_loops, 500) |
---|
378 | n/a | self.assertEqual(time_taken, 500/1024) |
---|
379 | n/a | expected = ('1 0.001\n' |
---|
380 | n/a | '2 0.002\n' |
---|
381 | n/a | '5 0.005\n' |
---|
382 | n/a | '10 0.010\n' |
---|
383 | n/a | '20 0.020\n' |
---|
384 | n/a | '50 0.049\n' |
---|
385 | n/a | '100 0.098\n' |
---|
386 | n/a | '200 0.195\n' |
---|
387 | n/a | '500 0.488\n') |
---|
388 | n/a | self.assertEqual(s.getvalue(), expected) |
---|
389 | n/a | |
---|
390 | n/a | |
---|
391 | n/a | if __name__ == '__main__': |
---|
392 | n/a | unittest.main() |
---|