Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97314:18630a74b4d0
Date: 2019-08-27 19:56 +0100
http://bitbucket.org/pypy/pypy/changeset/18630a74b4d0/
Log: Use @support.refcount_test to skip tests relying on
sys.getrefcount()
diff --git a/lib-python/3/ctypes/test/test_memfunctions.py
b/lib-python/3/ctypes/test/test_memfunctions.py
--- a/lib-python/3/ctypes/test/test_memfunctions.py
+++ b/lib-python/3/ctypes/test/test_memfunctions.py
@@ -52,7 +52,7 @@
self.assertEqual(cast(a, POINTER(c_byte))[:7:7],
[97])
- @support.refcount_test
+ #@support.refcount_test
def test_string_at(self):
s = string_at(b"foo bar")
# XXX The following may be wrong, depending on how Python
diff --git a/lib-python/3/ctypes/test/test_refcounts.py
b/lib-python/3/ctypes/test/test_refcounts.py
--- a/lib-python/3/ctypes/test/test_refcounts.py
+++ b/lib-python/3/ctypes/test/test_refcounts.py
@@ -13,10 +13,7 @@
@support.refcount_test
def test_1(self):
- try:
- from sys import getrefcount as grc
- except ImportError:
- return unittest.skip("no sys.getrefcount()")
+ from sys import getrefcount as grc
f = dll._testfunc_callback_i_if
f.restype = ctypes.c_int
@@ -41,10 +38,7 @@
@support.refcount_test
def test_refcount(self):
- try:
- from sys import getrefcount as grc
- except ImportError:
- return unittest.skip("no sys.getrefcount()")
+ from sys import getrefcount as grc
def func(*args):
pass
# this is the standard refcount for func
@@ -91,19 +85,15 @@
self.assertEqual(grc(func), 2)
class AnotherLeak(unittest.TestCase):
+ @support.refcount_test
def test_callback(self):
import sys
- try:
- from sys import getrefcount
- except ImportError:
- return unittest.skip("no sys.getrefcount()")
proto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_int)
def func(a, b):
return a * b * 2
f = proto(func)
- gc.collect()
a = sys.getrefcount(ctypes.c_int)
f(1, 2)
self.assertEqual(sys.getrefcount(ctypes.c_int), a)
diff --git a/lib-python/3/test/test_coroutines.py
b/lib-python/3/test/test_coroutines.py
--- a/lib-python/3/test/test_coroutines.py
+++ b/lib-python/3/test/test_coroutines.py
@@ -2078,15 +2078,6 @@
support.gc_collect()
self.assertIn("was never awaited", stderr.getvalue())
- def test_fatal_coro_warning(self):
- # Issue 27811
- async def func(): pass
- with warnings.catch_warnings(), support.captured_stderr() as stderr:
- warnings.filterwarnings("error")
- func()
- support.gc_collect()
- self.assertIn("was never awaited", stderr.getvalue())
-
class CoroAsyncIOCompatTest(unittest.TestCase):
diff --git a/lib-python/3/test/test_socket.py b/lib-python/3/test/test_socket.py
--- a/lib-python/3/test/test_socket.py
+++ b/lib-python/3/test/test_socket.py
@@ -4218,12 +4218,12 @@
self.write_file.write(self.write_msg)
self.write_file.flush()
+ @support.refcount_test
def testMakefileCloseSocketDestroy(self):
- if hasattr(sys, "getrefcount"):
- refcount_before = sys.getrefcount(self.cli_conn)
- self.read_file.close()
- refcount_after = sys.getrefcount(self.cli_conn)
- self.assertEqual(refcount_before - 1, refcount_after)
+ refcount_before = sys.getrefcount(self.cli_conn)
+ self.read_file.close()
+ refcount_after = sys.getrefcount(self.cli_conn)
+ self.assertEqual(refcount_before - 1, refcount_after)
def _testMakefileCloseSocketDestroy(self):
pass
diff --git a/lib-python/3/unittest/test/test_case.py
b/lib-python/3/unittest/test/test_case.py
--- a/lib-python/3/unittest/test/test_case.py
+++ b/lib-python/3/unittest/test/test_case.py
@@ -1287,8 +1287,7 @@
with self.assertRaises(TypeError):
self.assertRaises((ValueError, object))
- @unittest.skipUnless(hasattr(sys, 'getrefcount'),
- 'test needs sys.getrefcount()')
+ @support.refcount_test
def testAssertRaisesRefcount(self):
# bpo-23890: assertRaises() must not keep objects alive longer
# than expected
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit