blob: 0dcd8c5161ad1bfc581a526dc0298f6fba25bce0 [file] [log] [blame]
Guido van Rossum0b191782002-08-02 18:29:53 +00001"""Unittests for heapq."""
2
Raymond Hettinger2e3dfaf2004-06-13 05:26:33 +00003import sys
Ezio Melotti8269a442011-05-09 07:15:04 +03004import random
Ezio Melotti22ebb2d2013-01-02 21:19:37 +02005import unittest
Guido van Rossum0b191782002-08-02 18:29:53 +00006
Ezio Melotti8269a442011-05-09 07:15:04 +03007from test import support
8from unittest import TestCase, skipUnless
Raymond Hettinger35db4392014-05-30 02:28:36 -07009from operator import itemgetter
Ezio Melotti8269a442011-05-09 07:15:04 +030010
Nick Coghlan47384702009-04-22 16:13:36 +000011py_heapq = support.import_fresh_module('heapq', blocked=['_heapq'])
Ezio Melotti8269a442011-05-09 07:15:04 +030012c_heapq = support.import_fresh_module('heapq', fresh=['_heapq'])
Tim Petersaa7d2432002-08-03 02:11:26 +000013
Ezio Melotti8269a442011-05-09 07:15:04 +030014# _heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when
15# _heapq is imported, so check them there
Raymond Hettinger48f68d02014-06-14 16:43:35 -070016func_names = ['heapify', 'heappop', 'heappush', 'heappushpop', 'heapreplace',
17 '_heappop_max', '_heapreplace_max', '_heapify_max']
Ezio Melotti8269a442011-05-09 07:15:04 +030018
19class TestModules(TestCase):
20 def test_py_functions(self):
21 for fname in func_names:
22 self.assertEqual(getattr(py_heapq, fname).__module__, 'heapq')
23
24 @skipUnless(c_heapq, 'requires _heapq')
25 def test_c_functions(self):
26 for fname in func_names:
27 self.assertEqual(getattr(c_heapq, fname).__module__, '_heapq')
28
29
Ezio Melotti22ebb2d2013-01-02 21:19:37 +020030class TestHeap:
Tim Petersaa7d2432002-08-03 02:11:26 +000031
Raymond Hettingerbce036b2004-06-10 05:07:18 +000032 def test_push_pop(self):
33 # 1) Push 256 random numbers and pop them off, verifying all's OK.
34 heap = []
35 data = []
36 self.check_invariant(heap)
37 for i in range(256):
38 item = random.random()
39 data.append(item)
Christian Heimesd3eb5a152008-02-24 00:38:49 +000040 self.module.heappush(heap, item)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000041 self.check_invariant(heap)
42 results = []
43 while heap:
Christian Heimesd3eb5a152008-02-24 00:38:49 +000044 item = self.module.heappop(heap)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000045 self.check_invariant(heap)
46 results.append(item)
47 data_sorted = data[:]
48 data_sorted.sort()
49 self.assertEqual(data_sorted, results)
50 # 2) Check that the invariant holds for a sorted array
51 self.check_invariant(results)
52
Christian Heimesd3eb5a152008-02-24 00:38:49 +000053 self.assertRaises(TypeError, self.module.heappush, [])
Raymond Hettingere1defa42004-11-29 05:54:48 +000054 try:
Christian Heimesd3eb5a152008-02-24 00:38:49 +000055 self.assertRaises(TypeError, self.module.heappush, None, None)
56 self.assertRaises(TypeError, self.module.heappop, None)
Raymond Hettingere1defa42004-11-29 05:54:48 +000057 except AttributeError:
58 pass
Neal Norwitzd7be1182004-07-08 01:56:46 +000059
Raymond Hettingerbce036b2004-06-10 05:07:18 +000060 def check_invariant(self, heap):
61 # Check the heap invariant.
62 for pos, item in enumerate(heap):
63 if pos: # pos 0 has no parent
64 parentpos = (pos-1) >> 1
Benjamin Petersonc9c0f202009-06-30 23:06:06 +000065 self.assertTrue(heap[parentpos] <= item)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000066
67 def test_heapify(self):
68 for size in range(30):
69 heap = [random.random() for dummy in range(size)]
Christian Heimesd3eb5a152008-02-24 00:38:49 +000070 self.module.heapify(heap)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000071 self.check_invariant(heap)
72
Christian Heimesd3eb5a152008-02-24 00:38:49 +000073 self.assertRaises(TypeError, self.module.heapify, None)
Neal Norwitzd7be1182004-07-08 01:56:46 +000074
Raymond Hettingerbce036b2004-06-10 05:07:18 +000075 def test_naive_nbest(self):
76 data = [random.randrange(2000) for i in range(1000)]
77 heap = []
78 for item in data:
Christian Heimesd3eb5a152008-02-24 00:38:49 +000079 self.module.heappush(heap, item)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000080 if len(heap) > 10:
Christian Heimesd3eb5a152008-02-24 00:38:49 +000081 self.module.heappop(heap)
Raymond Hettingerbce036b2004-06-10 05:07:18 +000082 heap.sort()
83 self.assertEqual(heap, sorted(data)[-10:])
84
Christian Heimesd3eb5a152008-02-24 00:38:49 +000085 def heapiter(self, heap):
86 # An iterator returning a heap's elements, smallest-first.
87 try:
88 while 1:
89 yield self.module.heappop(heap)
90 except IndexError:
91 pass
92
Raymond Hettingerbce036b2004-06-10 05:07:18 +000093 def test_nbest(self):
94 # Less-naive "N-best" algorithm, much faster (if len(data) is big
95 # enough <wink>) than sorting all of data. However, if we had a max
96 # heap instead of a min heap, it could go faster still via
97 # heapify'ing all of data (linear time), then doing 10 heappops
98 # (10 log-time steps).
99 data = [random.randrange(2000) for i in range(1000)]
100 heap = data[:10]
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000101 self.module.heapify(heap)
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000102 for item in data[10:]:
103 if item > heap[0]: # this gets rarer the longer we run
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000104 self.module.heapreplace(heap, item)
105 self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:])
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000106
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000107 self.assertRaises(TypeError, self.module.heapreplace, None)
108 self.assertRaises(TypeError, self.module.heapreplace, None, None)
109 self.assertRaises(IndexError, self.module.heapreplace, [], None)
Neal Norwitzd7be1182004-07-08 01:56:46 +0000110
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000111 def test_nbest_with_pushpop(self):
112 data = [random.randrange(2000) for i in range(1000)]
113 heap = data[:10]
114 self.module.heapify(heap)
115 for item in data[10:]:
116 self.module.heappushpop(heap, item)
117 self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:])
118 self.assertEqual(self.module.heappushpop([], 'x'), 'x')
119
120 def test_heappushpop(self):
121 h = []
122 x = self.module.heappushpop(h, 10)
123 self.assertEqual((h, x), ([], 10))
124
125 h = [10]
126 x = self.module.heappushpop(h, 10.0)
127 self.assertEqual((h, x), ([10], 10.0))
128 self.assertEqual(type(h[0]), int)
129 self.assertEqual(type(x), float)
130
131 h = [10];
132 x = self.module.heappushpop(h, 9)
133 self.assertEqual((h, x), ([10], 9))
134
135 h = [10];
136 x = self.module.heappushpop(h, 11)
137 self.assertEqual((h, x), ([11], 10))
138
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000139 def test_heapsort(self):
140 # Exercise everything with repeated heapsort checks
Guido van Rossum805365e2007-05-07 22:24:25 +0000141 for trial in range(100):
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000142 size = random.randrange(50)
143 data = [random.randrange(25) for i in range(size)]
144 if trial & 1: # Half of the time, use heapify
145 heap = data[:]
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000146 self.module.heapify(heap)
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000147 else: # The rest of the time, use heappush
148 heap = []
149 for item in data:
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000150 self.module.heappush(heap, item)
151 heap_sorted = [self.module.heappop(heap) for i in range(size)]
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000152 self.assertEqual(heap_sorted, sorted(data))
153
Thomas Wouterscf297e42007-02-23 15:07:44 +0000154 def test_merge(self):
155 inputs = []
Raymond Hettinger35db4392014-05-30 02:28:36 -0700156 for i in range(random.randrange(25)):
157 row = []
158 for j in range(random.randrange(100)):
159 tup = random.choice('ABC'), random.randrange(-500, 500)
160 row.append(tup)
Thomas Wouterscf297e42007-02-23 15:07:44 +0000161 inputs.append(row)
Raymond Hettinger35db4392014-05-30 02:28:36 -0700162
163 for key in [None, itemgetter(0), itemgetter(1), itemgetter(1, 0)]:
164 for reverse in [False, True]:
165 seqs = []
166 for seq in inputs:
167 seqs.append(sorted(seq, key=key, reverse=reverse))
168 self.assertEqual(sorted(chain(*inputs), key=key, reverse=reverse),
169 list(self.module.merge(*seqs, key=key, reverse=reverse)))
170 self.assertEqual(list(self.module.merge()), [])
Thomas Wouterscf297e42007-02-23 15:07:44 +0000171
Raymond Hettinger46f5ca32013-09-14 20:51:57 -0700172 def test_merge_does_not_suppress_index_error(self):
173 # Issue 19018: Heapq.merge suppresses IndexError from user generator
174 def iterable():
175 s = list(range(10))
176 for i in range(20):
177 yield s[i] # IndexError when i > 10
178 with self.assertRaises(IndexError):
179 list(self.module.merge(iterable(), iterable()))
180
Thomas Wouterscf297e42007-02-23 15:07:44 +0000181 def test_merge_stability(self):
182 class Int(int):
183 pass
184 inputs = [[], [], [], []]
185 for i in range(20000):
186 stream = random.randrange(4)
187 x = random.randrange(500)
188 obj = Int(x)
189 obj.pair = (x, stream)
190 inputs[stream].append(obj)
191 for stream in inputs:
192 stream.sort()
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000193 result = [i.pair for i in self.module.merge(*inputs)]
Thomas Wouterscf297e42007-02-23 15:07:44 +0000194 self.assertEqual(result, sorted(result))
195
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000196 def test_nsmallest(self):
Thomas Wouters902d6eb2007-01-09 23:18:33 +0000197 data = [(random.randrange(2000), i) for i in range(1000)]
198 for f in (None, lambda x: x[0] * 547 % 2000):
199 for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000200 self.assertEqual(list(self.module.nsmallest(n, data)),
201 sorted(data)[:n])
202 self.assertEqual(list(self.module.nsmallest(n, data, key=f)),
Thomas Wouters902d6eb2007-01-09 23:18:33 +0000203 sorted(data, key=f)[:n])
Raymond Hettingerbce036b2004-06-10 05:07:18 +0000204
Raymond Hettinger4901a1f2004-12-02 08:59:14 +0000205 def test_nlargest(self):
Thomas Wouters902d6eb2007-01-09 23:18:33 +0000206 data = [(random.randrange(2000), i) for i in range(1000)]
207 for f in (None, lambda x: x[0] * 547 % 2000):
208 for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000209 self.assertEqual(list(self.module.nlargest(n, data)),
Guido van Rossumc1f779c2007-07-03 08:25:58 +0000210 sorted(data, reverse=True)[:n])
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000211 self.assertEqual(list(self.module.nlargest(n, data, key=f)),
Thomas Wouters902d6eb2007-01-09 23:18:33 +0000212 sorted(data, key=f, reverse=True)[:n])
Tim Petersaa7d2432002-08-03 02:11:26 +0000213
Amaury Forgeot d'Arcfdfe62d2008-06-17 20:36:03 +0000214 def test_comparison_operator(self):
Ezio Melottif9756c22011-05-09 18:36:53 +0300215 # Issue 3051: Make sure heapq works with both __lt__
Amaury Forgeot d'Arc2ba198d2008-06-17 21:25:35 +0000216 # For python 3.0, __le__ alone is not enough
Amaury Forgeot d'Arcfdfe62d2008-06-17 20:36:03 +0000217 def hsort(data, comp):
218 data = [comp(x) for x in data]
219 self.module.heapify(data)
220 return [self.module.heappop(data).x for i in range(len(data))]
221 class LT:
222 def __init__(self, x):
223 self.x = x
224 def __lt__(self, other):
225 return self.x > other.x
226 class LE:
227 def __init__(self, x):
228 self.x = x
Amaury Forgeot d'Arc35c86582008-06-17 21:11:29 +0000229 def __le__(self, other):
Amaury Forgeot d'Arcfdfe62d2008-06-17 20:36:03 +0000230 return self.x >= other.x
231 data = [random.random() for i in range(100)]
232 target = sorted(data, reverse=True)
233 self.assertEqual(hsort(data, LT), target)
Amaury Forgeot d'Arc2ba198d2008-06-17 21:25:35 +0000234 self.assertRaises(TypeError, data, LE)
Amaury Forgeot d'Arcfdfe62d2008-06-17 20:36:03 +0000235
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000236
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200237class TestHeapPython(TestHeap, TestCase):
Ezio Melottif9756c22011-05-09 18:36:53 +0300238 module = py_heapq
239
240
241@skipUnless(c_heapq, 'requires _heapq')
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200242class TestHeapC(TestHeap, TestCase):
Ezio Melottif9756c22011-05-09 18:36:53 +0300243 module = c_heapq
244
245
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000246#==============================================================================
247
248class LenOnly:
249 "Dummy sequence class defining __len__ but not __getitem__."
250 def __len__(self):
251 return 10
252
253class GetOnly:
254 "Dummy sequence class defining __getitem__ but not __len__."
255 def __getitem__(self, ndx):
256 return 10
257
258class CmpErr:
259 "Dummy element that always raises an error during comparison"
Mark Dickinsona56c4672009-01-27 18:17:45 +0000260 def __eq__(self, other):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000261 raise ZeroDivisionError
Mark Dickinsona56c4672009-01-27 18:17:45 +0000262 __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __eq__
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000263
264def R(seqn):
265 'Regular generator'
266 for i in seqn:
267 yield i
268
269class G:
270 'Sequence using __getitem__'
271 def __init__(self, seqn):
272 self.seqn = seqn
273 def __getitem__(self, i):
274 return self.seqn[i]
275
276class I:
277 'Sequence using iterator protocol'
278 def __init__(self, seqn):
279 self.seqn = seqn
280 self.i = 0
281 def __iter__(self):
282 return self
Georg Brandla18af4e2007-04-21 15:47:16 +0000283 def __next__(self):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000284 if self.i >= len(self.seqn): raise StopIteration
285 v = self.seqn[self.i]
286 self.i += 1
287 return v
288
289class Ig:
290 'Sequence using iterator protocol defined with a generator'
291 def __init__(self, seqn):
292 self.seqn = seqn
293 self.i = 0
294 def __iter__(self):
295 for val in self.seqn:
296 yield val
297
298class X:
299 'Missing __getitem__ and __iter__'
300 def __init__(self, seqn):
301 self.seqn = seqn
302 self.i = 0
Georg Brandla18af4e2007-04-21 15:47:16 +0000303 def __next__(self):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000304 if self.i >= len(self.seqn): raise StopIteration
305 v = self.seqn[self.i]
306 self.i += 1
307 return v
308
309class N:
Georg Brandla18af4e2007-04-21 15:47:16 +0000310 'Iterator missing __next__()'
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000311 def __init__(self, seqn):
312 self.seqn = seqn
313 self.i = 0
314 def __iter__(self):
315 return self
316
317class E:
318 'Test propagation of exceptions'
319 def __init__(self, seqn):
320 self.seqn = seqn
321 self.i = 0
322 def __iter__(self):
323 return self
Georg Brandla18af4e2007-04-21 15:47:16 +0000324 def __next__(self):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000325 3 // 0
326
327class S:
328 'Test immediate stop'
329 def __init__(self, seqn):
330 pass
331 def __iter__(self):
332 return self
Georg Brandla18af4e2007-04-21 15:47:16 +0000333 def __next__(self):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000334 raise StopIteration
335
Raymond Hettinger736c0ab2008-03-13 02:09:15 +0000336from itertools import chain
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000337def L(seqn):
338 'Test multiple tiers of iterators'
Raymond Hettingera6c60372008-03-13 01:26:19 +0000339 return chain(map(lambda x:x, R(Ig(G(seqn)))))
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000340
Ezio Melotti8269a442011-05-09 07:15:04 +0300341
Antoine Pitrou44d52142013-03-04 20:30:01 +0100342class SideEffectLT:
343 def __init__(self, value, heap):
344 self.value = value
345 self.heap = heap
346
347 def __lt__(self, other):
348 self.heap[:] = []
349 return self.value < other.value
350
351
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200352class TestErrorHandling:
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000353
354 def test_non_sequence(self):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000355 for f in (self.module.heapify, self.module.heappop):
Raymond Hettinger8a9c4d92011-04-13 11:49:57 -0700356 self.assertRaises((TypeError, AttributeError), f, 10)
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000357 for f in (self.module.heappush, self.module.heapreplace,
358 self.module.nlargest, self.module.nsmallest):
Raymond Hettinger8a9c4d92011-04-13 11:49:57 -0700359 self.assertRaises((TypeError, AttributeError), f, 10, 10)
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000360
361 def test_len_only(self):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000362 for f in (self.module.heapify, self.module.heappop):
Raymond Hettinger8a9c4d92011-04-13 11:49:57 -0700363 self.assertRaises((TypeError, AttributeError), f, LenOnly())
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000364 for f in (self.module.heappush, self.module.heapreplace):
Raymond Hettinger8a9c4d92011-04-13 11:49:57 -0700365 self.assertRaises((TypeError, AttributeError), f, LenOnly(), 10)
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000366 for f in (self.module.nlargest, self.module.nsmallest):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000367 self.assertRaises(TypeError, f, 2, LenOnly())
368
369 def test_get_only(self):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000370 for f in (self.module.heapify, self.module.heappop):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000371 self.assertRaises(TypeError, f, GetOnly())
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000372 for f in (self.module.heappush, self.module.heapreplace):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000373 self.assertRaises(TypeError, f, GetOnly(), 10)
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000374 for f in (self.module.nlargest, self.module.nsmallest):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000375 self.assertRaises(TypeError, f, 2, GetOnly())
376
377 def test_get_only(self):
378 seq = [CmpErr(), CmpErr(), CmpErr()]
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000379 for f in (self.module.heapify, self.module.heappop):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000380 self.assertRaises(ZeroDivisionError, f, seq)
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000381 for f in (self.module.heappush, self.module.heapreplace):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000382 self.assertRaises(ZeroDivisionError, f, seq, 10)
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000383 for f in (self.module.nlargest, self.module.nsmallest):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000384 self.assertRaises(ZeroDivisionError, f, 2, seq)
385
386 def test_arg_parsing(self):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000387 for f in (self.module.heapify, self.module.heappop,
388 self.module.heappush, self.module.heapreplace,
389 self.module.nlargest, self.module.nsmallest):
Raymond Hettinger8a9c4d92011-04-13 11:49:57 -0700390 self.assertRaises((TypeError, AttributeError), f, 10)
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000391
392 def test_iterable_args(self):
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000393 for f in (self.module.nlargest, self.module.nsmallest):
Guido van Rossum805365e2007-05-07 22:24:25 +0000394 for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)):
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000395 for g in (G, I, Ig, L, R):
Guido van Rossumc1f779c2007-07-03 08:25:58 +0000396 self.assertEqual(list(f(2, g(s))), list(f(2,s)))
397 self.assertEqual(list(f(2, S(s))), [])
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000398 self.assertRaises(TypeError, f, 2, X(s))
399 self.assertRaises(TypeError, f, 2, N(s))
400 self.assertRaises(ZeroDivisionError, f, 2, E(s))
401
Antoine Pitrou44d52142013-03-04 20:30:01 +0100402 # Issue #17278: the heap may change size while it's being walked.
403
404 def test_heappush_mutating_heap(self):
405 heap = []
406 heap.extend(SideEffectLT(i, heap) for i in range(200))
407 # Python version raises IndexError, C version RuntimeError
408 with self.assertRaises((IndexError, RuntimeError)):
409 self.module.heappush(heap, SideEffectLT(5, heap))
410
411 def test_heappop_mutating_heap(self):
412 heap = []
413 heap.extend(SideEffectLT(i, heap) for i in range(200))
414 # Python version raises IndexError, C version RuntimeError
415 with self.assertRaises((IndexError, RuntimeError)):
416 self.module.heappop(heap)
417
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000418
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200419class TestErrorHandlingPython(TestErrorHandling, TestCase):
Ezio Melottifd69abb2011-05-09 07:20:47 +0300420 module = py_heapq
421
Ezio Melotti19f7ca22011-05-09 07:27:20 +0300422@skipUnless(c_heapq, 'requires _heapq')
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200423class TestErrorHandlingC(TestErrorHandling, TestCase):
Ezio Melottifd69abb2011-05-09 07:20:47 +0300424 module = c_heapq
425
Raymond Hettinger855d9a92004-09-28 00:03:54 +0000426
Guido van Rossum0b191782002-08-02 18:29:53 +0000427if __name__ == "__main__":
Ezio Melotti22ebb2d2013-01-02 21:19:37 +0200428 unittest.main()