diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-04-23 23:18:50 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-04-23 23:18:50 +0000 |
commit | fc6670841863723ac0c17424705cb915adcd1a54 (patch) | |
tree | 23400d0e78036b4a1b133c20689b204164a4a8c4 | |
parent | 1893cbec881003d322ed2613542c09865310eabe (diff) | |
parent | 0102e2e1eed76e74652f082d7aec96855147c4a1 (diff) | |
download | python-swiftclient-fc6670841863723ac0c17424705cb915adcd1a54.tar.gz |
Merge "Updated test_shell for Python3"
-rw-r--r-- | tests/test_shell.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_shell.py b/tests/test_shell.py index 55967b6..b6f74f3 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -18,9 +18,17 @@ import os import tempfile import unittest +import six + import swiftclient import swiftclient.shell + +if six.PY2: + BUILTIN_OPEN = '__builtin__.open' +else: + BUILTIN_OPEN = 'builtins.open' + mocked_os_environ = { 'ST_AUTH': 'http://localhost:8080/auth/v1.0', 'ST_USER': 'test:tester', @@ -164,7 +172,7 @@ class TestShell(unittest.TestCase): mock.call(' 0')] mock_print.assert_has_calls(calls) - @mock.patch('__builtin__.open') + @mock.patch(BUILTIN_OPEN) @mock.patch('swiftclient.shell.Connection') def test_download(self, connection, mock_open): connection.return_value.get_object.return_value = [ @@ -217,7 +225,7 @@ class TestShell(unittest.TestCase): # Upload in segments argv = ["", "upload", "container", self.tmpfile, "-S", "10"] with open(self.tmpfile, "wb") as fh: - fh.write('12345678901234567890') + fh.write(b'12345678901234567890') swiftclient.shell.main(argv) connection.return_value.put_object.assert_called_with( 'container', |