diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-23 11:40:37 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-23 11:40:37 -0700 |
commit | 0102e2e1eed76e74652f082d7aec96855147c4a1 (patch) | |
tree | 190826bd90ab506251a5f27abbafa3e7dbce4bec /tests/test_shell.py | |
parent | 91075c32516156d259f79ad81e689bd65724415e (diff) | |
download | python-swiftclient-0102e2e1eed76e74652f082d7aec96855147c4a1.tar.gz |
Updated test_shell for Python3
Change-Id: Ia76e544fa6e0a222c260191a1ab74939078ed2fb
Diffstat (limited to 'tests/test_shell.py')
-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', |