mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
Add refcount test.
This commit is contained in:
parent
fa05ce3c1d
commit
105b084b59
1 changed files with 12 additions and 3 deletions
|
|
@ -74,7 +74,7 @@ class TestBasicOps(unittest.TestCase):
|
||||||
pop = range(n)
|
pop = range(n)
|
||||||
trials = 10000 # large num prevents false negatives without slowing normal case
|
trials = 10000 # large num prevents false negatives without slowing normal case
|
||||||
def factorial(n):
|
def factorial(n):
|
||||||
return n==0 and 1 or n * factorial(n-1)
|
return reduce(int.__mul__, xrange(1, n), 1)
|
||||||
for k in xrange(n):
|
for k in xrange(n):
|
||||||
expected = factorial(n) / factorial(n-k)
|
expected = factorial(n) / factorial(n-k)
|
||||||
perms = {}
|
perms = {}
|
||||||
|
|
@ -271,7 +271,7 @@ class TestModule(unittest.TestCase):
|
||||||
# tests validity but not completeness of the __all__ list
|
# tests validity but not completeness of the __all__ list
|
||||||
self.failUnless(Set(random.__all__) <= Set(dir(random)))
|
self.failUnless(Set(random.__all__) <= Set(dir(random)))
|
||||||
|
|
||||||
def test_main():
|
def test_main(verbose=None):
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
for testclass in (WichmannHill_TestBasicOps,
|
for testclass in (WichmannHill_TestBasicOps,
|
||||||
MersenneTwister_TestBasicOps,
|
MersenneTwister_TestBasicOps,
|
||||||
|
|
@ -280,5 +280,14 @@ def test_main():
|
||||||
suite.addTest(unittest.makeSuite(testclass))
|
suite.addTest(unittest.makeSuite(testclass))
|
||||||
test_support.run_suite(suite)
|
test_support.run_suite(suite)
|
||||||
|
|
||||||
|
# verify reference counting
|
||||||
|
import sys
|
||||||
|
if verbose and hasattr(sys, "gettotalrefcount"):
|
||||||
|
counts = []
|
||||||
|
for i in xrange(5):
|
||||||
|
test_support.run_suite(suite)
|
||||||
|
counts.append(sys.gettotalrefcount()-i)
|
||||||
|
print counts
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main(verbose=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue