def test_push_pop(self):
        # 1) Push 256 random numbers and pop them off, verifying all's OK.
        heap = []
        data = []
        self.check_invariant(heap)
        for i in range(256):
            item = random.random()
            data.append(item)
            heappush(heap, item)
            self.check_invariant(heap)
        results = []
        while heap:
            item = heappop(heap)
            self.check_invariant(heap)
            results.append(item)
        data_sorted = data[:]
        data_sorted.sort()
        self.assertEqual(data_sorted, results)
        # 2) Check that the invariant holds for a sorted array
        self.check_invariant(results)

        self.assertRaises(TypeError, heappush, [])
        try:
            self.assertRaises(TypeError, heappush, None, None)
            self.assertRaises(TypeError, heappop, None)
        except __HOLE__:
            pass
dataset/ETHPy150Open babble/babble/include/jython/Lib/test/test_heapq.py/TestHeap.test_push_pop