[Python-checkins] cpython (merge 3.3 -> default): #17789: merge with 3.3.
ezio.melotti
python-checkins at python.org
Fri Apr 19 04:46:23 CEST 2013
http://hg.python.org/cpython/rev/ac352d7d8058
changeset: 83448:ac352d7d8058
parent: 83446:4ea9a8e5ec21
parent: 83447:678564fc0962
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Apr 19 05:46:08 2013 +0300
summary:
#17789: merge with 3.3.
files:
Lib/test/test_random.py | 39 ++++++++--------------------
Misc/NEWS | 3 ++
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -10,7 +10,7 @@
from math import log, exp, pi, fsum, sin
from test import support
-class TestBasicOps(unittest.TestCase):
+class TestBasicOps:
# Superclass with tests common to all generators.
# Subclasses must arrange for self.gen to retrieve the Random instance
# to be tested.
@@ -188,7 +188,15 @@
k = sum(randrange(6755399441055744) % 3 == 2 for i in range(n))
self.assertTrue(0.30 < k/n < .37, (k/n))
-class SystemRandom_TestBasicOps(TestBasicOps):
+try:
+ random.SystemRandom().random()
+except NotImplementedError:
+ SystemRandom_available = False
+else:
+ SystemRandom_available = True
+
+ at unittest.skipUnless(SystemRandom_available, "random.SystemRandom not available")
+class SystemRandom_TestBasicOps(TestBasicOps, unittest.TestCase):
gen = random.SystemRandom()
def test_autoseed(self):
@@ -304,7 +312,7 @@
self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
-class MersenneTwister_TestBasicOps(TestBasicOps):
+class MersenneTwister_TestBasicOps(TestBasicOps, unittest.TestCase):
gen = random.Random()
def test_guaranteed_stable(self):
@@ -749,28 +757,5 @@
Subclass(newarg=1)
-def test_main(verbose=None):
- testclasses = [MersenneTwister_TestBasicOps,
- TestDistributions,
- TestModule]
-
- try:
- random.SystemRandom().random()
- except NotImplementedError:
- pass
- else:
- testclasses.append(SystemRandom_TestBasicOps)
-
- support.run_unittest(*testclasses)
-
- # verify reference counting
- import sys
- if verbose and hasattr(sys, "gettotalrefcount"):
- counts = [None] * 5
- for i in range(len(counts)):
- support.run_unittest(*testclasses)
- counts[i] = sys.gettotalrefcount()
- print(counts)
-
if __name__ == "__main__":
- test_main(verbose=True)
+ unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -134,6 +134,9 @@
- Issue #12820: add tests for the xml.dom.minicompat module.
Patch by John Chandler and Phil Connell.
+- Issue #17789: test_random now works with unittest test discovery.
+ Patch by Zachary Ware.
+
- Issue #17779: test_osx_env now works with unittest test discovery.
Patch by Zachary Ware.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list