mirror of
https://github.com/python/cpython.git
synced 2025-08-19 08:11:46 +00:00
mark ref counting as impl detail
This commit is contained in:
parent
694781b1d3
commit
7f8ede4db9
1 changed files with 3 additions and 4 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from test.test_support import run_unittest, TESTFN, unlink, have_unicode, \
|
from test.test_support import run_unittest, TESTFN, unlink, have_unicode, \
|
||||||
check_py3k_warnings, gc_collect
|
check_py3k_warnings, cpython_only
|
||||||
|
|
||||||
# Test result of triple loop (too big to inline)
|
# Test result of triple loop (too big to inline)
|
||||||
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
|
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
|
||||||
|
@ -793,8 +793,9 @@ class TestCase(unittest.TestCase):
|
||||||
(a, b), (c,) = IteratingSequenceClass(2), {42: 24}
|
(a, b), (c,) = IteratingSequenceClass(2), {42: 24}
|
||||||
self.assertEqual((a, b, c), (0, 1, 42))
|
self.assertEqual((a, b, c), (0, 1, 42))
|
||||||
|
|
||||||
# Test reference count behavior
|
|
||||||
|
|
||||||
|
@cpython_only
|
||||||
|
def test_ref_counting_behavior(self):
|
||||||
class C(object):
|
class C(object):
|
||||||
count = 0
|
count = 0
|
||||||
def __new__(cls):
|
def __new__(cls):
|
||||||
|
@ -807,7 +808,6 @@ class TestCase(unittest.TestCase):
|
||||||
x = C()
|
x = C()
|
||||||
self.assertEqual(C.count, 1)
|
self.assertEqual(C.count, 1)
|
||||||
del x
|
del x
|
||||||
gc_collect()
|
|
||||||
self.assertEqual(C.count, 0)
|
self.assertEqual(C.count, 0)
|
||||||
l = [C(), C(), C()]
|
l = [C(), C(), C()]
|
||||||
self.assertEqual(C.count, 3)
|
self.assertEqual(C.count, 3)
|
||||||
|
@ -816,7 +816,6 @@ class TestCase(unittest.TestCase):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
del l
|
del l
|
||||||
gc_collect()
|
|
||||||
self.assertEqual(C.count, 0)
|
self.assertEqual(C.count, 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue