From f3fe17bbc692080be4161ef072ed81a178a41eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@ericsson.com> Date: Mon, 2 Sep 2024 18:04:28 +0200 Subject: [PATCH] add unit tests for Python 2.7 --- .gitlab-ci.yml | 17 ++++++++++++++++- CHANGELOG.md | 1 + coolamqp/objects.py | 4 ++-- tests/test_objects.py | 4 +++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6421506..2a77fad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,7 +49,22 @@ unittest_select: AMQP_HOST: "rabbitmq" after_script: - mv .coverage .coverage.unitselect - + + + +unittest_epoll_python27: + extends: .before_test + image: python:2.7 + before_script: + - pip install nose2 coverage + - python setup.py install + script: + - coverage run --append -m nose2 -F -vv + variables: + AMQP_HOST: "rabbitmq" + after_script: + - mv .coverage .coverage.python27epoll + unittest_epoll: extends: .before_test diff --git a/CHANGELOG.md b/CHANGELOG.md index 161f339..d162323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,3 +10,4 @@ Since v1.3.2 they'll be put here and in release description. * stress tests will be harder, and use more queues * added arguments to queues, queue binds and exchanges * creating auto_delete non-exclusive queues will be met with a [PendingDeprecationWarning](https://www.rabbitmq.com/blog/2021/08/21/4.0-deprecation-announcements) +* added unit tests for Python 2.7 \ No newline at end of file diff --git a/coolamqp/objects.py b/coolamqp/objects.py index 597866f..57a8b0a 100644 --- a/coolamqp/objects.py +++ b/coolamqp/objects.py @@ -244,7 +244,7 @@ class Queue(object): :param exclusive: Is this queue exclusive? :param auto_delete: Is this queue auto_delete ? :param arguments: either a list of (bytes, values) or a dict of (str, value) to pass as an extra argument - :warn DeprecationWarning: if a non-exclusive auto_delete queue is created + :warn PendingDeprecationWarning: if a non-exclusive auto_delete queue is created """ __slots__ = ('name', 'durable', 'exchange', 'auto_delete', 'exclusive', 'anonymous', 'consumer_tag', 'arguments') @@ -266,7 +266,7 @@ class Queue(object): self.exclusive = exclusive self.arguments = argumentify(arguments) if self.auto_delete and not self.exclusive: - warnings.warn('This will be removed in RabbitMQ 4.0', DeprecationWarning) + warnings.warn('This will be removed in RabbitMQ 4.0', PendingDeprecationWarning) self.anonymous = not len( self.name) # if this queue is anonymous, it must be regenerated upon reconnect diff --git a/tests/test_objects.py b/tests/test_objects.py index e4f3a4e..fbd7c76 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -2,6 +2,7 @@ from __future__ import print_function, absolute_import, division import unittest +import sys from coolamqp.objects import NodeDefinition, MessageProperties, Queue @@ -12,8 +13,9 @@ class TestObjects(unittest.TestCase): ce_p_msg = MessageProperties(content_encoding=b'wtf') self.assertIn('wtf', str(ce_p_msg)) + @unittest.skipIf(sys.platform.startswith('2'), 'Only Python 3 has assertWarns') def test_warning(self): - with self.assertWarns(DeprecationWarning): + with self.assertWarns(PendingDeprecationWarning): Queue(auto_delete=True, exclusive=False) def test_node_definition_from_amqp(self): -- GitLab