def test_releaseRaisesOSError(self):
        """
        An L{OSError} raised within
        L{_ExhaustsFileDescriptors.release} with an C{errno} other than
        C{EBADF} is reraised to the caller.
        """
        fakeFileDescriptors = []

        def opensThree():
            if len(fakeFileDescriptors) == 3:
                raise OSError(errno.EMFILE, "Too many files")
            fakeFileDescriptors.append(-1)
            return fakeFileDescriptors[-1]

        def failingClose(fd):
            raise OSError(11, "test_releaseRaisesOSError fake OSError")

        exhauster = _ExhaustsFileDescriptors(opensThree,
                                             close=failingClose)

        self.assertEqual(exhauster.count(), 0)
        exhauster.exhaust()
        self.assertGreater(exhauster.count(), 0)
        self.assertRaises(OSError, exhauster.release)

        An L{OSError} raised within
        L{_ExhaustsFileDescriptors.release} with an C{errno} other than
        C{EBADF} is reraised to the caller.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_tcp.py