Py3.7 compatibility for failing unit tests
Handle StopIteration for Py3.7. PEP 0479, https://www.python.org/dev/peps/pep-0479/, makes the following change: "when StopIteration is raised inside a generator, it is replaced it with RuntimeError". And states: "If raise StopIteration occurs directly in a generator, simply replace it with return." Also update expected dict ordering in test_update() for Python versions newer than 3.5. Change-Id: I9847053534ffd47c4559d504be647be0de25b651 Closes-Bug: #1784714
This commit is contained in:
parent
99aeb00ab5
commit
b81547798f
|
@ -15,6 +15,7 @@
|
|||
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import mock
|
||||
|
@ -50,15 +51,26 @@ class TestController(testtools.TestCase):
|
|||
body = self.c.update('test-id', type_name='test_name',
|
||||
remove_props=remove_props, update1=1, update2=2)
|
||||
self.assertEqual(self.mock_body, body)
|
||||
patch_kwargs = {
|
||||
'headers': {'Content-Type': 'application/json-patch+json'},
|
||||
'json': [
|
||||
{'path': '/remove1', 'value': None, 'op': 'replace'},
|
||||
{'path': '/remove2', 'value': None, 'op': 'replace'},
|
||||
{'path': '/update2', 'value': 2, 'op': 'add'},
|
||||
{'path': '/update1', 'value': 1, 'op': 'add'}
|
||||
]
|
||||
}
|
||||
if sys.version_info > (3, 5):
|
||||
patch_kwargs = {
|
||||
'headers': {'Content-Type': 'application/json-patch+json'},
|
||||
'json': [
|
||||
{'op': 'replace', 'path': '/remove1', 'value': None},
|
||||
{'op': 'replace', 'path': '/remove2', 'value': None},
|
||||
{'op': 'add', 'path': '/update1', 'value': 1},
|
||||
{'op': 'add', 'path': '/update2', 'value': 2}
|
||||
]
|
||||
}
|
||||
else:
|
||||
patch_kwargs = {
|
||||
'headers': {'Content-Type': 'application/json-patch+json'},
|
||||
'json': [
|
||||
{'path': '/remove1', 'value': None, 'op': 'replace'},
|
||||
{'path': '/remove2', 'value': None, 'op': 'replace'},
|
||||
{'path': '/update2', 'value': 2, 'op': 'add'},
|
||||
{'path': '/update1', 'value': 1, 'op': 'add'}
|
||||
]
|
||||
}
|
||||
self.mock_http_client.patch.assert_called_once_with(
|
||||
'/artifacts/checked_name/test-id', **patch_kwargs)
|
||||
self.c._check_type_name.assert_called_once_with('test_name')
|
||||
|
|
|
@ -171,7 +171,7 @@ class Controller(object):
|
|||
if limit:
|
||||
limit -= 1
|
||||
if limit <= 0:
|
||||
raise StopIteration
|
||||
return
|
||||
|
||||
try:
|
||||
next_url = body['next']
|
||||
|
|
Loading…
Reference in New Issue