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.five import Empty
|
||||||
from kombu.utils.encoding import bytes_to_str, ensure_bytes
|
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
|
from . import virtual
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -141,7 +140,7 @@ class Channel(virtual.Channel):
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
conninfo = self.connection.client
|
conninfo = self.connection.client
|
||||||
self.vhost = os.path.join('/', conninfo.virtual_host[0:-1])
|
self.vhost = self._normalize_chroot(conninfo.virtual_host)
|
||||||
hosts = []
|
hosts = []
|
||||||
if conninfo.alt:
|
if conninfo.alt:
|
||||||
for host_port in conninfo.alt:
|
for host_port in conninfo.alt:
|
||||||
|
@ -166,6 +165,13 @@ class Channel(virtual.Channel):
|
||||||
conn.start()
|
conn.start()
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _normalize_chroot(chroot):
|
||||||
|
chroot = chroot.rstrip('/')
|
||||||
|
if not len(chroot) or chroot[0] != '/':
|
||||||
|
chroot = '/' + chroot
|
||||||
|
return chroot
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self):
|
def client(self):
|
||||||
if self._client is None:
|
if self._client is None:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
|
import pytest
|
||||||
from case import skip
|
from case import skip
|
||||||
|
|
||||||
from kombu import Connection
|
from kombu import Connection
|
||||||
|
@ -25,3 +26,12 @@ class test_Channel:
|
||||||
|
|
||||||
self.channel._queues['foo'] = AssertQueue()
|
self.channel._queues['foo'] = AssertQueue()
|
||||||
self.channel._put(queue='foo', message='bar')
|
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