Skip to content

Commit

Permalink
Fix tests with unicode and isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Nov 7, 2015
1 parent b928846 commit dae0b25
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions channels/backends/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,6 @@ def unlock_channel(self, channel):

def __str__(self):
return "%s(alias=%s)" % (self.__class__.__name__, self.connection.alias)

def flush(self):
pass
6 changes: 6 additions & 0 deletions channels/backends/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ def unlock_channel(self, channel):
Unlocks the named channel. Always succeeds.
"""
locks.discard(channel)

def flush(self):
global queues, groups, locks
queues = {}
groups = {}
locks = set()
9 changes: 4 additions & 5 deletions channels/backends/redis_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ def connection(self, index):
host, port = self.hosts[index]
return redis.Redis(host=host, port=port)

@property
def connections(self):
for i in range(len(self.hosts)):
return self.connection(i)

def send(self, channel, message):
# if channel is no str (=> bytes) convert it
if not isinstance(channel, str):
Expand Down Expand Up @@ -189,3 +184,7 @@ def unlock_channel(self, channel):

def __str__(self):
return "%s(hosts=%s)" % (self.__class__.__name__, self.hosts)

def flush(self):
for i in range(self.ring_size):
self.connection(i).flushdb()
1 change: 1 addition & 0 deletions channels/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MemoryBackendTests(TestCase):

def setUp(self):
self.backend = self.backend_class(routing={})
self.backend.flush()

def test_send_recv(self):
"""
Expand Down

0 comments on commit dae0b25

Please sign in to comment.