mirror of https://github.com/celery/kombu.git
Fix last chroot character trimming
This commit is contained in:
parent
2e528de742
commit
5f35ef996c
|
@ -28,8 +28,7 @@ import socket
|
|||
|
||||
from kombu.five import Empty
|
||||
from kombu.utils.encoding import bytes_to_str, ensure_bytes
|
||||
from kombu.utils.json import loads, dumps
|
||||
|
||||
from kombu.utils.json import dumps, loads
|
||||
from . import virtual
|
||||
|
||||
try:
|
||||
|
@ -141,7 +140,7 @@ class Channel(virtual.Channel):
|
|||
|
||||
def _open(self):
|
||||
conninfo = self.connection.client
|
||||
self.vhost = os.path.join('/', conninfo.virtual_host[0:-1])
|
||||
self.vhost = self._normalize_chroot(conninfo.virtual_host)
|
||||
hosts = []
|
||||
if conninfo.alt:
|
||||
for host_port in conninfo.alt:
|
||||
|
@ -166,6 +165,13 @@ class Channel(virtual.Channel):
|
|||
conn.start()
|
||||
return conn
|
||||
|
||||
@staticmethod
|
||||
def _normalize_chroot(chroot):
|
||||
chroot = chroot.rstrip('/')
|
||||
if not len(chroot) or chroot[0] != '/':
|
||||
chroot = '/' + chroot
|
||||
return chroot
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
if self._client is None:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import pytest
|
||||
from case import skip
|
||||
|
||||
from kombu import Connection
|
||||
|
@ -25,3 +26,12 @@ class test_Channel:
|
|||
|
||||
self.channel._queues['foo'] = AssertQueue()
|
||||
self.channel._put(queue='foo', message='bar')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected', (
|
||||
('/', '/'),
|
||||
('/root', '/root'),
|
||||
('/root/', '/root'),
|
||||
))
|
||||
def test_normalize_chroot(input, expected):
|
||||
assert zookeeper.Channel._normalize_chroot(input) == expected
|
||||
|
|
Loading…
Reference in New Issue