From f3e14ead36ad0cc599236fbe2d99bf7d585054d8 Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Fri, 20 Oct 2017 05:06:40 -0700 Subject: _queue_declare() should return queue name as string not bytes --- Modules/_librabbitmq/connection.c | 3 +-- Modules/_librabbitmq/connection.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/_librabbitmq/connection.c b/Modules/_librabbitmq/connection.c index b3979eb..623fdbe 100644 --- a/Modules/_librabbitmq/connection.c +++ b/Modules/_librabbitmq/connection.c @@ -1654,8 +1654,7 @@ PyRabbitMQ_Connection_queue_declare(PyRabbitMQ_Connection *self, goto bail; if ((ret = PyTuple_New(3)) == NULL) goto bail; - PyTuple_SET_ITEM(ret, 0, PyBytes_FromStringAndSize(ok->queue.bytes, - (Py_ssize_t)ok->queue.len)); + PyTuple_SET_ITEM(ret, 0, PySTRING_FROM_AMQBYTES(ok->queue)); PyTuple_SET_ITEM(ret, 1, PyInt_FromLong((long)ok->message_count)); PyTuple_SET_ITEM(ret, 2, PyInt_FromLong((long)ok->consumer_count)); return ret; diff --git a/Modules/_librabbitmq/connection.h b/Modules/_librabbitmq/connection.h index e734e75..273ae75 100644 --- a/Modules/_librabbitmq/connection.h +++ b/Modules/_librabbitmq/connection.h @@ -89,10 +89,10 @@ buffer_toMemoryView(char *buf, Py_ssize_t buf_len) { #if PY_MAJOR_VERSION == 2 # define PySTRING_FROM_AMQBYTES(member) \ - PyString_FromStringAndSize(member.bytes, (Py_ssize_t)member.len); + PyString_FromStringAndSize((member).bytes, (Py_ssize_t)(member).len) #else # define PySTRING_FROM_AMQBYTES(member) \ - PyUnicode_FromStringAndSize(member.bytes, (Py_ssize_t)member.len); + PyUnicode_FromStringAndSize((member).bytes, (Py_ssize_t)(member).len) #endif -- cgit v1.2.1 From 6b305521cb91d337ffa8a4e6f41b627a9afbb74c Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Fri, 20 Oct 2017 05:07:11 -0700 Subject: Add python3 support in unittests --- funtests/config.py | 2 +- funtests/setup.py | 1 - librabbitmq/tests/test_functional.py | 9 +++++---- requirements/README.rst | 13 ------------- requirements/default.txt | 1 + requirements/test.txt | 2 +- setup.py | 7 +++++++ 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/funtests/config.py b/funtests/config.py index 8e3cec4..1b95423 100644 --- a/funtests/config.py +++ b/funtests/config.py @@ -7,7 +7,7 @@ BROKER_USER = os.environ.get('BROKER_USER', 'guest') BROKER_PASSWORD = os.environ.get('BROKER_PASSWORD', 'guest') from functools import partial -from unittest2 import TestCase +from unittest import TestCase from uuid import uuid4 diff --git a/funtests/setup.py b/funtests/setup.py index fa6f625..5116dd6 100644 --- a/funtests/setup.py +++ b/funtests/setup.py @@ -45,7 +45,6 @@ setup( build_requires=[ "nose", "nose-cover3", - "unittest2", "coverage>=3.0", ], classifiers=[ diff --git a/librabbitmq/tests/test_functional.py b/librabbitmq/tests/test_functional.py index 2dc9bd6..03d6276 100644 --- a/librabbitmq/tests/test_functional.py +++ b/librabbitmq/tests/test_functional.py @@ -1,8 +1,9 @@ from __future__ import absolute_import -from __future__ import with_statement + +from six.moves import xrange import socket -import unittest2 as unittest +import unittest from librabbitmq import Message, Connection, ConnectionError, ChannelError TEST_QUEUE = 'pyrabbit.testq' @@ -86,7 +87,7 @@ class test_Channel(unittest.TestCase): for i in xrange(100): self.connection.drain_events(timeout=0.2) - self.assertEquals(len(messages), 100) + self.assertEqual(len(messages), 100) def test_timeout(self): """Check that our ``drain_events`` call actually times out if @@ -110,7 +111,7 @@ class test_Channel(unittest.TestCase): with self.assertRaises(socket.timeout): self.connection.drain_events(timeout=0.1) - self.assertEquals(len(messages), 1) + self.assertEqual(len(messages), 1) def tearDown(self): if self.channel and self.connection.connected: diff --git a/requirements/README.rst b/requirements/README.rst index 1175f71..ffe49f4 100644 --- a/requirements/README.rst +++ b/requirements/README.rst @@ -14,10 +14,6 @@ Index Requirements needed to run the full unittest suite. -* :file:`requirements/test3.txt` - - Requirements needed to run the full unittest suite on Python 3. - * :file:`requirements/test-ci.txt` Extra test requirements required by the CI suite (Tox). @@ -41,12 +37,3 @@ Running the tests $ pip install -U -r requirements/default.txt $ pip install -U -r requirements/test.txt - - -Running the tests on Python 3 ------------------------------ - -:: - - $ pip install -U -r requirements/default.txt - $ pip install -U -r requirements/test3.txt diff --git a/requirements/default.txt b/requirements/default.txt index 22439cb..6fa7e25 100644 --- a/requirements/default.txt +++ b/requirements/default.txt @@ -1 +1,2 @@ +six>=1.0.0 amqp>=1.4.6 diff --git a/requirements/test.txt b/requirements/test.txt index 70e6505..1f4031d 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,3 +1,3 @@ -unittest2>=0.4.0 nose mock +six diff --git a/setup.py b/setup.py index 8228d69..0b94c10 100644 --- a/setup.py +++ b/setup.py @@ -195,6 +195,13 @@ if 'bdist_egg' in sys.argv and 'build' not in sys.argv: sys.argv[:_index] + ['build', 'bdist_egg'] + sys.argv[_index + 1:] ) +# 'test doesn't always call build for some reason +if 'test' in sys.argv and 'build' not in sys.argv: + _index = sys.argv.index('test') + sys.argv[:] = ( + sys.argv[:_index] + ['build', 'test'] + sys.argv[_index + 1:] + ) + setup( name='librabbitmq', version=version, -- cgit v1.2.1