Ticket #2245: cdefer.5.patch

File cdefer.5.patch, 1.8 KB (added by Peaker, 7 years ago)

Use test.skip = '...' instead of in-test logic.

  • twisted/test/test_defer.py

     
    284284        self.failIf(L, "Deferred failed too soon.") 
    285285        return d 
    286286    testTimeOut.suppress = [_setTimeoutSuppression] 
     287    if not hasattr(defer.Deferred, 'setTimeout'): 
     288        testTimeOut.skip = "setTimeout not supported, skipping" 
    287289 
    288290 
    289291    def testImmediateSuccess(self): 
     
    304306        d.addCallback(l.append) 
    305307        self.assertEquals(l, ["success"]) 
    306308    test_immediateSuccessBeforeTimeout.suppress = [_setTimeoutSuppression] 
     309    if not hasattr(defer.Deferred, 'setTimeout'): 
     310        test_immediateSuccessBeforeTimeout.skip = "setTimeout not supported, skipping" 
    307311 
    308312 
    309313    def testImmediateFailure(self): 
  • twisted/internet/defer.py

     
    439439        return False 
    440440 
    441441try: 
    442     from twisted.internet.cdefer import Deferred 
     442    from twisted.internet.cdefer import Deferred as CDeferred 
    443443except ImportError: 
    444444    pass 
    445445else: 
    446     # Stubs for setDebugging/getDebugging for backwards compatibility 
    447     # when using cdefer. 
    448     is_debug = False 
     446    PyDeferred = Deferred 
     447    PyDeferred.debug = True 
     448    # Debugging enabled via use of PyDeferred 
    449449    def setDebugging(new_value): 
    450         global is_debug 
     450        global is_debug, Deferred 
    451451        is_debug = new_value 
     452        if is_debug: 
     453            Deferred = PyDeferred 
     454        else: 
     455            Deferred = CDeferred 
    452456    def getDebugging(): 
    453457        global is_debug 
    454458        return is_debug 
    455459 
     460    setDebugging(False) 
     461 
    456462class DeferredList(Deferred): 
    457463    """I combine a group of deferreds into one callback. 
    458464