mirror of
https://github.com/django/daphne.git
synced 2025-06-30 09:53: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):
|
def __str__(self):
|
||||||
return "%s(alias=%s)" % (self.__class__.__name__, self.connection.alias)
|
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.
|
Unlocks the named channel. Always succeeds.
|
||||||
"""
|
"""
|
||||||
locks.discard(channel)
|
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]
|
host, port = self.hosts[index]
|
||||||
return redis.Redis(host=host, port=port)
|
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):
|
def send(self, channel, message):
|
||||||
# if channel is no str (=> bytes) convert it
|
# if channel is no str (=> bytes) convert it
|
||||||
if not isinstance(channel, str):
|
if not isinstance(channel, str):
|
||||||
|
@ -189,3 +184,7 @@ class RedisChannelBackend(BaseChannelBackend):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s(hosts=%s)" % (self.__class__.__name__, self.hosts)
|
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):
|
def setUp(self):
|
||||||
self.backend = self.backend_class(routing={})
|
self.backend = self.backend_class(routing={})
|
||||||
|
self.backend.flush()
|
||||||
|
|
||||||
def test_send_recv(self):
|
def test_send_recv(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user