Update ReSizeSteam.next() to ReSizeSteam__next__()

1. The bug.
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/opt/stack/freezer/freezer/tests/unit/openstack/test_backup.py", line 37, in test_backup_cinder_by_glance
    self.bakup_os.backup_cinder_by_glance(35)

      File "/opt/stack/freezer/freezer/openstack/backup.py", line 79, in backup_cinder_by_glance
    self.storage.add_stream(stream, package, headers=headers)

      File "/opt/stack/freezer/freezer/storage/swift.py", line 163, in add_stream
    for el in stream:

    TypeError: iter() returned non-iterator of type 'ReSizeStream'
2. Fix
In python3.x , a iterator object should be difined two funs " __iter__()" and "__next__()".

Update ReSizeSteam.next() to ReSizeSteam.__next__().

Change-Id: I940841b94789d024d3b9447f96158963fe3e16ee
This commit is contained in:
Caihui 2020-06-30 19:06:37 -07:00
parent 58cb979a40
commit 7244bef734
2 changed files with 1 additions and 5 deletions

View File

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
import sys
import unittest
from freezer.openstack import backup
from freezer.tests import commons
@ -31,8 +29,6 @@ class TestBackup(commons.FreezerBaseTestCase):
self.client_manager = self.backup_opt.client_manager
self.storage = self.backup_opt.storage
@unittest.skipIf(sys.version_info.major == 3,
'Not supported on python v 3.x')
def test_backup_cinder_by_glance(self):
self.bakup_os.backup_cinder_by_glance(35)

View File

@ -263,7 +263,7 @@ class ReSizeStream(object):
def __iter__(self):
return self
def next(self):
def __next__(self):
LOG.debug("Transmitted {0} of {1}".format(self.transmitted,
self.length))
chunk_size = self.chunk_size