Merge "py3: make storlets tools as py3 compatible"

This commit is contained in:
Zuul 2018-07-10 08:38:52 +00:00 committed by Gerrit Code Review
commit bb405dbda4
5 changed files with 19 additions and 14 deletions

View File

@ -14,13 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import ConfigParser
from six.moves import configparser
class ClusterConfig(object):
def __init__(self, config_path):
config = ConfigParser.ConfigParser()
config = configparser.ConfigParser()
config.read(config_path)
options = config.options('general')
self.conf = {}

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from cStringIO import StringIO
from six.moves import StringIO
class FakeStorletFile(object):

View File

@ -14,13 +14,17 @@
# limitations under the License.
from IPython.core.error import UsageError
from cStringIO import StringIO
from six.moves import StringIO
from storlets.tools.extensions.ipython import StorletMagics
import unittest
import mock
import os
import itertools
import six
if six.PY3:
from io import FileIO as file
class FakeConnection(object):
def __init__(self, fake_status=200, fake_headers=None, fake_iter=None):
@ -127,7 +131,7 @@ class TestStorletMagicStorletApp(BaseTestIpythonExtension, unittest.TestCase):
self._call_storletapp(line, cell)
self.assertEqual(
'--with-invoke option requires --input to run the app',
cm.exception.message)
cm.exception.args[0])
def test_storlet_magics_invalid_input_fail(self):
invalid_input_patterns = (
@ -143,7 +147,7 @@ class TestStorletMagicStorletApp(BaseTestIpythonExtension, unittest.TestCase):
self.assertEqual(
'swift object path must have the format: '
'"path:/<container>/<object>"',
cm.exception.message)
cm.exception.args[0])
def test_storlet_magics_stdout(self):
line = 'test.TestStorlet --with-invoke --input path:/foo/bar' \
@ -185,7 +189,7 @@ class TestStorletMagicStorletApp(BaseTestIpythonExtension, unittest.TestCase):
self.assertEqual(
"You need to set OS_AUTH_URL, OS_USERNAME, OS_PASSWORD "
"and OS_PROJECT_NAME for Swift authentication",
e.exception.message)
e.exception.args[0])
def test_storlet_auth_v2_not_supported(self):
line = 'test.TestStorlet'
@ -195,7 +199,7 @@ class TestStorletMagicStorletApp(BaseTestIpythonExtension, unittest.TestCase):
self._call_storletapp(line, cell)
self.assertEqual(
'keystone v2 is not supported',
e.exception.message)
e.exception.args[0])
def test_storlet_auth_v1_no_enough_auth_info(self):
# NOTE: Now, storlets should work on keystone v3 so that this test
@ -233,7 +237,7 @@ class TestStorletMagicStorletApp(BaseTestIpythonExtension, unittest.TestCase):
self.assertEqual(
"You need to set ST_AUTH, ST_USER, ST_KEY "
"for Swift authentication",
e.exception.message)
e.exception.args[0])
class TestStorletMagicGet(BaseTestIpythonExtension, unittest.TestCase):
@ -284,7 +288,7 @@ class TestStorletMagicGet(BaseTestIpythonExtension, unittest.TestCase):
for scenario in scenarios:
with self.assertRaises(UsageError) as e:
self._call_get(scenario['line'])
self.assertEqual(scenario['msg'], e.exception.message)
self.assertEqual(scenario['msg'], e.exception.args[0])
def _test_get(self, line, outvar_name):
self._call_get(line)
@ -380,7 +384,7 @@ class TestStorletMagicCopy(BaseTestIpythonExtension, unittest.TestCase):
for scenario in scenarios:
with self.assertRaises(UsageError) as e:
self._call_copy(scenario['line'])
self.assertEqual(scenario['msg'], e.exception.message)
self.assertEqual(scenario['msg'], e.exception.args[0])
def _test_copy(self, line, outvar_name):
self._call_copy(line)
@ -459,7 +463,7 @@ class TestStorletMagicPut(BaseTestIpythonExtension, unittest.TestCase):
for scenario in scenarios:
with self.assertRaises(UsageError) as e:
self._call_put(scenario['line'])
self.assertEqual(scenario['msg'], e.exception.message)
self.assertEqual(scenario['msg'], e.exception.args[0])
def _test_put(self, line, outvar_name):
open_name = '%s.open' % 'storlets.tools.extensions.ipython'

View File

@ -53,4 +53,4 @@ class TestTestTools(TestCase):
fake_storlet_out.set_metadata({})
self.assertEqual(
"Sending metadata twice is not allowed",
cm.exception.message)
cm.exception.args[0])

View File

@ -34,7 +34,8 @@ basepython = python3
commands =
nosetests -v \
tests/unit/gateway \
tests/unit/sbus
tests/unit/sbus \
tests/unit/tools
[testenv:py36]
basepython = python3