mirror of
https://github.com/django/daphne.git
synced 2025-06-04 13:13:06 +03:00
Fix tests with unicode and isolation
This commit is contained in:
parent
b928846391
commit
dae0b257d6
|
@ -168,3 +168,6 @@ class DatabaseChannelBackend(BaseChannelBackend):
|
|||
|
||||
def __str__(self):
|
||||
return "%s(alias=%s)" % (self.__class__.__name__, self.connection.alias)
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
|
|
@ -92,3 +92,9 @@ class InMemoryChannelBackend(BaseChannelBackend):
|
|||
Unlocks the named channel. Always succeeds.
|
||||
"""
|
||||
locks.discard(channel)
|
||||
|
||||
def flush(self):
|
||||
global queues, groups, locks
|
||||
queues = {}
|
||||
groups = {}
|
||||
locks = set()
|
||||
|
|
|
@ -61,11 +61,6 @@ class RedisChannelBackend(BaseChannelBackend):
|
|||
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):
|
||||
|
@ -189,3 +184,7 @@ class RedisChannelBackend(BaseChannelBackend):
|
|||
|
||||
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()
|
||||
|
|
|
@ -13,6 +13,7 @@ class MemoryBackendTests(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.backend = self.backend_class(routing={})
|
||||
self.backend.flush()
|
||||
|
||||
def test_send_recv(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user