def testDeferredYielding(self):
        """
        Ensure that yielding a Deferred directly is trapped as an
        error.
        """
        # See the comment _deferGenerator about d.callback(Deferred).
        def _genDeferred():
            yield getThing()
        _genDeferred = deprecatedDeferredGenerator(_genDeferred)

        return self.assertFailure(_genDeferred(), TypeError)

        Ensure that yielding a Deferred directly is trapped as an
        error.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_defgen.py