Merge "Enable running unit tests in py37 environment"

This commit is contained in:
Zuul 2019-12-10 20:18:57 +00:00 committed by Gerrit Code Review
commit 6ff39f3a4d
3 changed files with 20 additions and 3 deletions

View File

@ -162,8 +162,12 @@ class TestConfluentKafkaConsumer(base.BaseTestCase):
m.set_value("message{}".format(i))
messages.append(m)
self.consumer._consumer.poll.side_effect = messages
for index, message in enumerate(self.consumer):
self.assertEqual(message, messages[index])
try:
for index, message in enumerate(self.consumer):
self.assertEqual(message, messages[index])
except RuntimeError as re:
if 'generator raised StopIteration' in str(re):
pass
@mock.patch('confluent_kafka.Message')
@mock.patch('confluent_kafka.KafkaError')

View File

@ -173,6 +173,10 @@ class TestKafkaConsumer(base.BaseTestCase):
mock_set_partitioner.return_value.acquired = True
mock_set_partitioner.return_value.__iter__.return_value = [1]
list(self.monasca_kafka_consumer)
try:
list(self.monasca_kafka_consumer)
except RuntimeError as re:
if 'generator raised StopIteration' in str(re):
pass
self.consumer.seek.assert_called_once_with(0, 0)

View File

@ -34,6 +34,15 @@ commands =
{[testenv]commands}
stestr run --blacklist-file {env:BLACKLIST_FILE} {posargs}
[testenv:py37]
basepython = python3.7
setenv =
{[testenv]setenv}
BLACKLIST_FILE={toxinidir}/test-blacklist-py3.txt
commands =
{[testenv]commands}
stestr run --blacklist-file {env:BLACKLIST_FILE} {posargs}
[testenv:cover]
setenv =
PYTHON=coverage run --source monasca_common --parallel-mode