Procházet zdrojové kódy

Fixed intermittent beeswax parallel test failures.

bc Wong před 15 roky
rodič
revize
3013ddc48d
1 změnil soubory, kde provedl 12 přidání a 6 odebrání
  1. 12 6
      apps/beeswax/src/beeswax/test_base.py

+ 12 - 6
apps/beeswax/src/beeswax/test_base.py

@@ -236,12 +236,18 @@ def verify_history(client, fragment, design=None, reverse=False):
   if design:
     my_assert(design in resp.content)
 
-  context = resp.context
-  if context:
-    return len(context['page'].object_list)
-  else:
-    LOG.warn('Cannot find history size. Response context is None')
-    return -1
+  if resp.context:
+    try:
+      return len(resp.context['page'].object_list)
+    except KeyError:
+      pass
+
+  # This could happen if we issue multiple requests in parallel.
+  # The capturing of Django response context is not thread safe.
+  # Also see:
+  #   http://docs.djangoproject.com/en/1.2/topics/testing/#testing-responses
+  LOG.warn('Cannot find history size. Response context clobbered')
+  return -1
 
 
 class BeeswaxSampleProvider(object):