def METHOD_NAME(self, function: Callable[[], object]) -> defer.Deferred:
    sentinel_context = current_context()
    callback_completed = False
    with LoggingContext("one"):
        # fire off function, but don't wait on it.
        d2 = run_in_background(function)
        def cb(res: object) -> object:
            nonlocal callback_completed
            callback_completed = True
            return res
        d2.addCallback(cb)
        self._check_test_key("one")
    # now wait for the function under test to have run, and check that
    # the logcontext is left in a sane state.
    d2 = defer.Deferred()
    def check_logcontext() -> None:
        if not callback_completed:
            reactor.callLater(0.01, check_logcontext)
            return
        # make sure that the context was reset before it got thrown back
        # into the reactor
        try:
            self.assertIs(current_context(), sentinel_context)
            d2.callback(None)
        except BaseException:
            d2.errback(twisted.python.failure.Failure())
    reactor.callLater(0.01, check_logcontext)
    # test is done once d2 finishes
    return d2