Skip test in test_socket.py if `sys.getrefcount` isn't available (#126640)

Skip `testMakefileCloseSocketDestroy` test if `sys.getrefcount` isn't available. This is necessary for  PyPy and other Python implementations that do not have `sys.getrefcount`.
This commit is contained in:
CF Bolz-Tereick 2024-11-10 16:16:36 +01:00 committed by GitHub
parent 160758a574
commit 0f6bb28ff3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -5334,6 +5334,8 @@ class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
self.write_file.write(self.write_msg)
self.write_file.flush()
@unittest.skipUnless(hasattr(sys, 'getrefcount'),
'test needs sys.getrefcount()')
def testMakefileCloseSocketDestroy(self):
refcount_before = sys.getrefcount(self.cli_conn)
self.read_file.close()