From bfe1ad451589f0ef64c8eecf80e448ca3e5af7e7 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:10:44 +0200 Subject: [PATCH] fixed unit tests for Python 2.7 --- .gitlab-ci.yml | 6 +++--- setup.py | 2 +- tests/test_objects.py | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dd811a4..5fd1bf0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: alias: rabbitmq before_script: - python setup.py install - - pip install --break-system-packages nose2 coverage requests yapf unittest2 + - pip install --break-system-packages nose2 coverage requests yapf - coverage run --append -m compile_definitions artifacts: paths: @@ -56,10 +56,10 @@ unittest_epoll_python27: extends: .before_test image: python:2.7 before_script: - - pip install nose2 coverage unittest2 + - pip install nose2 - python setup.py install script: - - coverage run --append -m nose2 -F -vv + - nose2 -F -vv variables: AMQP_HOST: "rabbitmq" after_script: diff --git a/setup.py b/setup.py index bb97edd..00144ae 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup(keywords=['amqp', 'rabbitmq', 'client', 'network', 'ha', 'high availabilit version=__version__, packages=find_packages(include=['coolamqp', 'coolamqp.*']), install_requires=['six'], - tests_require=["pytest", "coverage", "unittest2"], + tests_require=["pytest", "coverage"], test_suite='nose2.collector.collector', python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', extras_require={ diff --git a/tests/test_objects.py b/tests/test_objects.py index ee1c7cb..37f335d 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -1,21 +1,24 @@ # coding=UTF-8 from __future__ import print_function, absolute_import, division -import unittest2 -import sys +import unittest +import warnings from coolamqp.objects import NodeDefinition, MessageProperties, Queue -class TestObjects(unittest2.TestCase): +class TestObjects(unittest.TestCase): def test_message_properties(self): empty_p_msg = MessageProperties() ce_p_msg = MessageProperties(content_encoding=b'wtf') self.assertIn('wtf', str(ce_p_msg)) def test_warning(self): - with self.assertWarns(PendingDeprecationWarning): + warnings.resetwarnings() + with warnings.catch_warnings(record=True) as w: Queue(auto_delete=True, exclusive=False) + self.assertEqual(len(w), 1) + self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning)) def test_node_definition_from_amqp(self): n1 = NodeDefinition(u'amqp://ala:ma@kota/psa') -- GitLab