diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-05-29 11:54:55 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-05-29 11:54:55 +0000 |
| commit | 3338ed91d4b9a0a33885d48969d71de0d30bed7e (patch) | |
| tree | 424baec18a45abcc29ce0919a04ec424ba3f14cc /glanceclient | |
| parent | f7598479d13c518d74d55696e347b5485cd7787e (diff) | |
| parent | bb2a5e946f36fc28ffa138357d644c2b7ec52242 (diff) | |
| download | python-glanceclient-3338ed91d4b9a0a33885d48969d71de0d30bed7e.tar.gz | |
Merge "Downloading image with --progress fails for python3"
Diffstat (limited to 'glanceclient')
| -rw-r--r-- | glanceclient/common/utils.py | 3 | ||||
| -rw-r--r-- | glanceclient/tests/unit/test_progressbar.py | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 0221bf4..3c10e4d 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -471,6 +471,9 @@ class IterableWithLength(object): def next(self): return next(self.iterable) + # In Python 3, __next__() has replaced next(). + __next__ = next + def __len__(self): return self.length diff --git a/glanceclient/tests/unit/test_progressbar.py b/glanceclient/tests/unit/test_progressbar.py index 1dd42a0..1841cd0 100644 --- a/glanceclient/tests/unit/test_progressbar.py +++ b/glanceclient/tests/unit/test_progressbar.py @@ -19,6 +19,7 @@ import six import testtools from glanceclient.common import progressbar +from glanceclient.common import utils from glanceclient.tests import utils as test_utils @@ -26,12 +27,13 @@ class TestProgressBarWrapper(testtools.TestCase): def test_iter_iterator_display_progress_bar(self): size = 100 - iterator = iter('X' * 100) + iterator_with_len = utils.IterableWithLength(iter('X' * 100), size) saved_stdout = sys.stdout try: sys.stdout = output = test_utils.FakeTTYStdout() # Consume iterator. - data = list(progressbar.VerboseIteratorWrapper(iterator, size)) + data = list(progressbar.VerboseIteratorWrapper(iterator_with_len, + size)) self.assertEqual(['X'] * 100, data) self.assertEqual( '[%s>] 100%%\n' % ('=' * 29), |
