def test_deferredFailure(self):
        """
        Check that L{threads.deferToThread} return a failure object
        with an appropriate exception instance when the called
        function raises an exception.
        """
        class NewError(Exception):
            pass
        def raiseError():
            raise NewError()
        d = threads.deferToThread(raiseError)
        return self.assertFailure(d, NewError)

        Check that L{threads.deferToThread} return a failure object
        with an appropriate exception instance when the called
        function raises an exception.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_threads.py