diff -r 701069f9888c Lib/test/test_heapq.py --- a/Lib/test/test_heapq.py Sat Apr 23 01:24:11 2011 +0200 +++ b/Lib/test/test_heapq.py Sat Apr 23 04:58:45 2011 +0300 @@ -2,12 +2,18 @@ import random import unittest +from unittest import skipUnless from test import support import sys # We do a bit of trickery here to be able to test both the C implementation # and the Python implementation of the module. -import heapq as c_heapq +try: + import _heapq +except ImportError: + c_heapq = None +else: + import heapq as c_heapq py_heapq = support.import_fresh_module('heapq', blocked=['_heapq']) class TestHeap(unittest.TestCase): @@ -185,7 +191,7 @@ self.assertFalse(sys.modules['heapq'] is self.module) self.assertTrue(hasattr(self.module.heapify, '__code__')) - +@skipUnless(c_heapq, 'test requires the _heapq module') class TestHeapC(TestHeap): module = c_heapq @@ -307,6 +313,7 @@ 'Test multiple tiers of iterators' return chain(map(lambda x:x, R(Ig(G(seqn))))) +@skipUnless(c_heapq, 'test requires the _heapq module') class TestErrorHandling(unittest.TestCase): # only for C implementation module = c_heapq