Enable running unit tests in py37 environment
Until now no unit tests have been executed in py37 environment. This change fixes tox configuration to enable running these tests. It also fixes two unit tests to handle PEP479 being enabled for all code in Python 3.7 [1, 2]. [1] https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior [2] https://stackoverflow.com/questions/51700960/runtimeerror-generator-raised-stopiteration-every-time-i-try-to-run-app Change-Id: I7fcf30d848efb8dc4cc6ca19056868aa6127cf60
This commit is contained in:
parent
b70afb9bf6
commit
231f3b4760
@ -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')
|
||||
|
@ -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)
|
||||
|
9
tox.ini
9
tox.ini
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user