Browse Source

Tests passing

Ask Solem 11 năm trước cách đây
mục cha
commit
ebef9c1f30

+ 2 - 2
celery/local.py

@@ -249,11 +249,10 @@ class PromiseProxy(Proxy):
                              '_Proxy__kwargs')):
                              '_Proxy__kwargs')):
         try:
         try:
             thing = Proxy._get_current_object(self)
             thing = Proxy._get_current_object(self)
-            object.__setattr__(self, '__thing', thing)
-            return thing
         except:
         except:
             raise
             raise
         else:
         else:
+            object.__setattr__(self, '__thing', thing)
             for attr in _clean:
             for attr in _clean:
                 try:
                 try:
                     object.__delattr__(self, attr)
                     object.__delattr__(self, attr)
@@ -274,6 +273,7 @@ class PromiseProxy(Proxy):
                         object.__delattr__(self, '__pending__')
                         object.__delattr__(self, '__pending__')
                     except AttributeError:
                     except AttributeError:
                         pass
                         pass
+            return thing
 
 
 
 
 def maybe_evaluate(obj):
 def maybe_evaluate(obj):

+ 1 - 0
celery/tests/utils/test_local.py

@@ -341,6 +341,7 @@ class test_PromiseProxy(Case):
         self.assertTrue(object.__getattribute__(p, '__pending__'))
         self.assertTrue(object.__getattribute__(p, '__pending__'))
 
 
         self.assertTrue(repr(p))
         self.assertTrue(repr(p))
+        self.assertTrue(p.__evaluated__())
         with self.assertRaises(AttributeError):
         with self.assertRaises(AttributeError):
             object.__getattribute__(p, '__pending__')
             object.__getattribute__(p, '__pending__')
         cbA.assert_called_with(p)
         cbA.assert_called_with(p)