mirror of https://github.com/celery/kombu.git
Merge branch 'EnTeQuAk/master'
This commit is contained in:
commit
52530446f2
|
@ -11,7 +11,7 @@ from kombu.serialization import registry, register, SerializerNotInstalled, \
|
|||
unregister, register_pickle
|
||||
|
||||
from kombu.tests.utils import unittest
|
||||
from kombu.tests.utils import mask_modules
|
||||
from kombu.tests.utils import mask_modules, skip_if_not_module
|
||||
|
||||
# For content_encoding tests
|
||||
unicode_string = u'abcdé\u8463'
|
||||
|
@ -120,28 +120,18 @@ class test_Serialization(unittest.TestCase):
|
|||
content_type='application/json',
|
||||
content_encoding='utf-8'))
|
||||
|
||||
@skip_if_not_module('msgpack')
|
||||
def test_msgpack_decode(self):
|
||||
register_msgpack()
|
||||
try:
|
||||
__import__("msgpack")
|
||||
except ImportError:
|
||||
say("* msgpack-python not installed, will not execute "
|
||||
"related tests.")
|
||||
raise SkipTest("msgpack-python not installed")
|
||||
self.assertEquals(msgpack_py_data,
|
||||
registry.decode(
|
||||
msgpack_data,
|
||||
content_type='application/x-msgpack',
|
||||
content_encoding='binary'))
|
||||
|
||||
@skip_if_not_module('msgpack')
|
||||
def test_msgpack_encode(self):
|
||||
register_msgpack()
|
||||
try:
|
||||
__import__("msgpack")
|
||||
except ImportError:
|
||||
say("* msgpack-python not installed, will not execute "
|
||||
"related tests.")
|
||||
raise SkipTest("msgpack-python not installed")
|
||||
self.assertEquals(registry.decode(
|
||||
registry.encode(msgpack_py_data, serializer="msgpack")[-1],
|
||||
content_type='application/x-msgpack',
|
||||
|
@ -151,26 +141,18 @@ class test_Serialization(unittest.TestCase):
|
|||
content_type='application/x-msgpack',
|
||||
content_encoding='binary'))
|
||||
|
||||
@skip_if_not_module('yaml')
|
||||
def test_yaml_decode(self):
|
||||
register_yaml()
|
||||
try:
|
||||
__import__("yaml")
|
||||
except ImportError:
|
||||
say("* PyYAML not installed, will not execute related tests.")
|
||||
raise SkipTest("PyYAML not installed")
|
||||
self.assertEquals(py_data,
|
||||
registry.decode(
|
||||
yaml_data,
|
||||
content_type='application/x-yaml',
|
||||
content_encoding='utf-8'))
|
||||
|
||||
@skip_if_not_module('yaml')
|
||||
def test_yaml_encode(self):
|
||||
register_yaml()
|
||||
try:
|
||||
__import__("yaml")
|
||||
except ImportError:
|
||||
say("* PyYAML not installed, will not execute related tests.")
|
||||
raise SkipTest("PyYAML not installed")
|
||||
self.assertEquals(registry.decode(
|
||||
registry.encode(py_data, serializer="yaml")[-1],
|
||||
content_type='application/x-yaml',
|
||||
|
|
|
@ -19,7 +19,7 @@ class test_amqplib(unittest.TestCase):
|
|||
|
||||
c = BrokerConnection(port=None, transport=Transport).connect()
|
||||
self.assertEqual(c["host"],
|
||||
"localhost:%s" % (Transport.default_port, ))
|
||||
"127.0.0.1:%s" % (Transport.default_port, ))
|
||||
|
||||
def test_custom_port(self):
|
||||
|
||||
|
@ -27,4 +27,4 @@ class test_amqplib(unittest.TestCase):
|
|||
Connection = MockConnection
|
||||
|
||||
c = BrokerConnection(port=1337, transport=Transport).connect()
|
||||
self.assertEqual(c["host"], "localhost:1337")
|
||||
self.assertEqual(c["host"], "127.0.0.1:1337")
|
||||
|
|
|
@ -10,7 +10,7 @@ else:
|
|||
from kombu import utils
|
||||
from kombu.utils.functional import wraps
|
||||
|
||||
from kombu.tests.utils import redirect_stdouts, mask_modules
|
||||
from kombu.tests.utils import redirect_stdouts, mask_modules, skip_if_module
|
||||
|
||||
partition = utils._compat_partition
|
||||
rpartition = utils._compat_rpartition
|
||||
|
@ -93,6 +93,7 @@ class test_UUID(unittest.TestCase):
|
|||
self.assertIsInstance(i1, str)
|
||||
self.assertNotEqual(i1, i2)
|
||||
|
||||
@skip_if_module('__pypy__')
|
||||
def test_gen_unique_id_without_ctypes(self):
|
||||
old_utils = sys.modules.pop("kombu.utils")
|
||||
|
||||
|
|
|
@ -110,5 +110,34 @@ def skip_if_environ(env_var_name):
|
|||
return _wrap_test
|
||||
|
||||
|
||||
def skip_if_module(module):
|
||||
def _wrap_test(fun):
|
||||
@wraps(fun)
|
||||
def _skip_if_module(*args, **kwargs):
|
||||
try:
|
||||
__import__(module)
|
||||
raise SkipTest("SKIP %s: %s available\n" % (
|
||||
fun.__name__, module))
|
||||
except ImportError:
|
||||
pass
|
||||
return fun(*args, **kwargs)
|
||||
return _skip_if_module
|
||||
return _wrap_test
|
||||
|
||||
|
||||
def skip_if_not_module(module):
|
||||
def _wrap_test(fun):
|
||||
@wraps(fun)
|
||||
def _skip_if_not_module(*args, **kwargs):
|
||||
try:
|
||||
__import__(module)
|
||||
except ImportError:
|
||||
raise SkipTest("SKIP %s: %s available\n" % (
|
||||
fun.__name__, module))
|
||||
return fun(*args, **kwargs)
|
||||
return _skip_if_not_module
|
||||
return _wrap_test
|
||||
|
||||
|
||||
def skip_if_quick(fun):
|
||||
return skip_if_environ("QUICKTEST")(fun)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
nose
|
||||
nose-cover3
|
||||
unittest2>=0.5.0
|
||||
coverage>=3.0
|
||||
simplejson
|
||||
PyYAML==3.09 # 3.10 dropped 2.4 support
|
10
tox.ini
10
tox.ini
|
@ -1,5 +1,5 @@
|
|||
[tox]
|
||||
envlist = py24,py25,py26,py27
|
||||
envlist = py24,py25,py26,py27,pypy
|
||||
|
||||
[testenv]
|
||||
distribute = True
|
||||
|
@ -39,3 +39,11 @@ commands = pip -E {envdir} install -r contrib/requirements/default.txt
|
|||
nosetests --with-xunit --xunit-file=nosetests.xml \
|
||||
--with-coverage3 --cover3-xml \
|
||||
--cover3-xml-file=coverage.xml
|
||||
|
||||
[testenv:pypy]
|
||||
basepython = pypy
|
||||
commands = pip -E {envdir} install -r contrib/requirements/default.txt
|
||||
pip -E {envdir} install -r contrib/requirements/test-pypy.txt
|
||||
nosetests --with-xunit --xunit-file=nosetests.xml \
|
||||
--with-coverage3 --cover3-xml \
|
||||
--cover3-xml-file=coverage.xml
|
||||
|
|
Loading…
Reference in New Issue