summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_heapq.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-01-02 19:19:37 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-01-02 19:19:37 (GMT)
commit22ebb2d6ef6d822f93240e5e89ba1d7b8bc8b6c5 (patch)
tree9f9e68347ec94ccaaa05f874f7e9f7c182c1112a /Lib/test/test_heapq.py
parentc52703720718736082f9bbb15fe35b8e0c5dc551 (diff)
downloadcpython-22ebb2d6ef6d822f93240e5e89ba1d7b8bc8b6c5.zip
cpython-22ebb2d6ef6d822f93240e5e89ba1d7b8bc8b6c5.tar.gz
cpython-22ebb2d6ef6d822f93240e5e89ba1d7b8bc8b6c5.tar.bz2
#16748: test_heapq now works with unittest test discovery.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r--Lib/test/test_heapq.py35
1 files changed, 8 insertions, 27 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index e0c49c1..54395c0 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -2,6 +2,7 @@
import sys
import random
+import unittest
from test import support
from unittest import TestCase, skipUnless
@@ -25,8 +26,7 @@ class TestModules(TestCase):
self.assertEqual(getattr(c_heapq, fname).__module__, '_heapq')
-class TestHeap(TestCase):
- module = None
+class TestHeap:
def test_push_pop(self):
# 1) Push 256 random numbers and pop them off, verifying all's OK.
@@ -214,12 +214,12 @@ class TestHeap(TestCase):
self.assertRaises(TypeError, data, LE)
-class TestHeapPython(TestHeap):
+class TestHeapPython(TestHeap, TestCase):
module = py_heapq
@skipUnless(c_heapq, 'requires _heapq')
-class TestHeapC(TestHeap):
+class TestHeapC(TestHeap, TestCase):
module = c_heapq
@@ -319,8 +319,7 @@ def L(seqn):
return chain(map(lambda x:x, R(Ig(G(seqn)))))
-class TestErrorHandling(TestCase):
- module = None
+class TestErrorHandling:
def test_non_sequence(self):
for f in (self.module.heapify, self.module.heappop):
@@ -371,31 +370,13 @@ class TestErrorHandling(TestCase):
self.assertRaises(ZeroDivisionError, f, 2, E(s))
-class TestErrorHandlingPython(TestErrorHandling):
+class TestErrorHandlingPython(TestErrorHandling, TestCase):
module = py_heapq
@skipUnless(c_heapq, 'requires _heapq')
-class TestErrorHandlingC(TestErrorHandling):
+class TestErrorHandlingC(TestErrorHandling, TestCase):
module = c_heapq
-#==============================================================================
-
-
-def test_main(verbose=None):
- test_classes = [TestModules, TestHeapPython, TestHeapC,
- TestErrorHandlingPython, TestErrorHandlingC]
- support.run_unittest(*test_classes)
-
- # verify reference counting
- if verbose and hasattr(sys, "gettotalrefcount"):
- import gc
- counts = [None] * 5
- for i in range(len(counts)):
- support.run_unittest(*test_classes)
- gc.collect()
- counts[i] = sys.gettotalrefcount()
- print(counts)
-
if __name__ == "__main__":
- test_main(verbose=True)
+ unittest.main()