[pypy-svn] pypy default: Skip calls to sys.getrefcount()
amauryfa
commits-noreply at bitbucket.org
Thu Jan 27 19:27:37 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r41406:a48e598aff68
Date: 2011-01-27 18:57 +0100
http://bitbucket.org/pypy/pypy/changeset/a48e598aff68/
Log: Skip calls to sys.getrefcount()
diff --git a/lib-python/modified-2.7.0/test/test_memoryview.py b/lib-python/modified-2.7.0/test/test_memoryview.py
--- a/lib-python/modified-2.7.0/test/test_memoryview.py
+++ b/lib-python/modified-2.7.0/test/test_memoryview.py
@@ -25,7 +25,8 @@
def check_getitem_with_type(self, tp):
item = self.getitem_type
b = tp(self._source)
- oldrefcount = sys.getrefcount(b)
+ if hasattr(sys, 'getrefcount'):
+ oldrefcount = sys.getrefcount(b)
m = self._view(b)
self.assertEquals(m[0], item(b"a"))
self.assertIsInstance(m[0], bytes)
@@ -42,7 +43,8 @@
self.assertRaises(TypeError, lambda: m[0.0])
self.assertRaises(TypeError, lambda: m["a"])
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ if hasattr(sys, 'getrefcount'):
+ self.assertEquals(sys.getrefcount(b), oldrefcount)
def test_getitem(self):
for tp in self._types:
@@ -64,7 +66,8 @@
if not self.ro_type:
return
b = self.ro_type(self._source)
- oldrefcount = sys.getrefcount(b)
+ if hasattr(sys, 'getrefcount'):
+ oldrefcount = sys.getrefcount(b)
m = self._view(b)
def setitem(value):
m[0] = value
@@ -72,14 +75,16 @@
self.assertRaises(TypeError, setitem, 65)
self.assertRaises(TypeError, setitem, memoryview(b"a"))
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ if hasattr(sys, 'getrefcount'):
+ self.assertEquals(sys.getrefcount(b), oldrefcount)
def test_setitem_writable(self):
if not self.rw_type:
return
tp = self.rw_type
b = self.rw_type(self._source)
- oldrefcount = sys.getrefcount(b)
+ if hasattr(sys, 'getrefcount'):
+ oldrefcount = sys.getrefcount(b)
m = self._view(b)
m[0] = tp(b"0")
self._check_contents(tp, b, b"0bcdef")
@@ -115,7 +120,8 @@
self.assertRaises(ValueError, setitem, slice(0,2), b"a")
m = None
- self.assertEquals(sys.getrefcount(b), oldrefcount)
+ if hasattr(sys, 'getrefcount'):
+ self.assertEquals(sys.getrefcount(b), oldrefcount)
def test_delitem(self):
for tp in self._types:
@@ -281,6 +287,7 @@
def _check_contents(self, tp, obj, contents):
self.assertEquals(obj[1:7], tp(contents))
+ @unittest.skipUnless(hasattr(sys, 'getrefcount'), "Reference counting")
def test_refs(self):
for tp in self._types:
m = memoryview(tp(self._source))
More information about the Pypy-commit
mailing list