Permalink
Browse files

Reset client descriptors at the start of event tests.

Fixes #6958
  • Loading branch information...
showell authored and timabbott committed Oct 11, 2017
1 parent 941f718 commit f0194f18216453db41bbc6811af4be351f0d6188
Showing with 23 additions and 1 deletion.
  1. +13 −1 zerver/tests/test_events.py
  2. +10 −0 zerver/tornado/event_queue.py
@@ -93,7 +93,11 @@
from zerver.views.events_register import _default_all_public_streams, _default_narrow
from zerver.tornado.event_queue import allocate_client_descriptor, EventQueue
from zerver.tornado.event_queue import (
allocate_client_descriptor,
clear_client_event_queues_for_testing,
EventQueue,
)
from zerver.tornado.views import get_events_backend
from collections import OrderedDict
@@ -403,6 +407,14 @@ def realm_bot_schema(self, field_name, check):
def do_test(self, action, event_types=None, include_subscribers=True, state_change_expected=True,
num_events=1):
# type: (Callable[[], Any], Optional[List[str]], bool, bool, int) -> List[Dict[str, Any]]
'''
Make sure we have a clean slate of client descriptors for these tests.
If we don't do this, then certain failures will only manifest when you
run multiple tests.
'''
clear_client_event_queues_for_testing()
client = allocate_client_descriptor(
dict(user_profile_id = self.user_profile.id,
user_profile_email = self.user_profile.email,
@@ -336,6 +336,16 @@ def contents(self):
next_queue_id = 0
def clear_client_event_queues_for_testing():
# type: () -> None
assert(settings.TEST_SUITE)
clients.clear()
user_clients.clear()
realm_clients_all_streams.clear()
gc_hooks.clear()
global next_queue_id
next_queue_id = 0
def add_client_gc_hook(hook):
# type: (Callable[[int, ClientDescriptor, bool], None]) -> None
gc_hooks.append(hook)

0 comments on commit f0194f1

Please sign in to comment.