From 3924ab0db446658149aec4d7b089f063f9e4088b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 5 Oct 2015 16:28:01 +0200 Subject: [PATCH] Port api test_common to Python 3 * Replace gen.next() with next(gen) * tox.ini: Add glance.tests.unit.api.test_common to Python 3.4 Change-Id: If9c730db8b29e58ed87d8e587c03461ac7a921cd --- glance/tests/unit/api/test_common.py | 50 ++++++++++++++-------------- tox.ini | 1 + 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/glance/tests/unit/api/test_common.py b/glance/tests/unit/api/test_common.py index 3a61671a74..55a35e2b23 100644 --- a/glance/tests/unit/api/test_common.py +++ b/glance/tests/unit/api/test_common.py @@ -55,9 +55,9 @@ class TestSizeCheckedIter(testtools.TestCase): checked_image = glance.api.common.size_checked_iter( resp, meta, 4, ['AB', 'CD'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('CD', checked_image.next()) - self.assertRaises(StopIteration, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('CD', next(checked_image)) + self.assertRaises(StopIteration, next, checked_image) def test_small_last_chunk(self): resp = self._get_webob_response() @@ -65,9 +65,9 @@ class TestSizeCheckedIter(testtools.TestCase): checked_image = glance.api.common.size_checked_iter( resp, meta, 3, ['AB', 'C'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('C', checked_image.next()) - self.assertRaises(StopIteration, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('C', next(checked_image)) + self.assertRaises(StopIteration, next, checked_image) def test_variable_chunk_size(self): resp = self._get_webob_response() @@ -75,11 +75,11 @@ class TestSizeCheckedIter(testtools.TestCase): checked_image = glance.api.common.size_checked_iter( resp, meta, 6, ['AB', '', 'CDE', 'F'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('', checked_image.next()) - self.assertEqual('CDE', checked_image.next()) - self.assertEqual('F', checked_image.next()) - self.assertRaises(StopIteration, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('', next(checked_image)) + self.assertEqual('CDE', next(checked_image)) + self.assertEqual('F', next(checked_image)) + self.assertRaises(StopIteration, next, checked_image) def test_too_many_chunks(self): """An image should streamed regardless of expected_size""" @@ -88,10 +88,10 @@ class TestSizeCheckedIter(testtools.TestCase): checked_image = glance.api.common.size_checked_iter( resp, meta, 4, ['AB', 'CD', 'EF'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('CD', checked_image.next()) - self.assertEqual('EF', checked_image.next()) - self.assertRaises(exception.GlanceException, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('CD', next(checked_image)) + self.assertEqual('EF', next(checked_image)) + self.assertRaises(exception.GlanceException, next, checked_image) def test_too_few_chunks(self): resp = self._get_webob_response() @@ -100,9 +100,9 @@ class TestSizeCheckedIter(testtools.TestCase): ['AB', 'CD'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('CD', checked_image.next()) - self.assertRaises(exception.GlanceException, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('CD', next(checked_image)) + self.assertRaises(exception.GlanceException, next, checked_image) def test_too_much_data(self): resp = self._get_webob_response() @@ -111,9 +111,9 @@ class TestSizeCheckedIter(testtools.TestCase): ['AB', 'CD'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('CD', checked_image.next()) - self.assertRaises(exception.GlanceException, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('CD', next(checked_image)) + self.assertRaises(exception.GlanceException, next, checked_image) def test_too_little_data(self): resp = self._get_webob_response() @@ -122,10 +122,10 @@ class TestSizeCheckedIter(testtools.TestCase): ['AB', 'CD', 'E'], None) - self.assertEqual('AB', checked_image.next()) - self.assertEqual('CD', checked_image.next()) - self.assertEqual('E', checked_image.next()) - self.assertRaises(exception.GlanceException, checked_image.next) + self.assertEqual('AB', next(checked_image)) + self.assertEqual('CD', next(checked_image)) + self.assertEqual('E', next(checked_image)) + self.assertRaises(exception.GlanceException, next, checked_image) class TestMalformedRequest(test_utils.BaseTestCase): diff --git a/tox.ini b/tox.ini index d19defe2b8..443c88936d 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ downloadcache = ~/cache/pip [testenv:py34] commands = python -m testtools.run \ + glance.tests.unit.api.test_common \ glance.tests.unit.common.test_client \ glance.tests.unit.common.test_config \ glance.tests.unit.common.test_exception \