diff --git a/swift/cli/ringbuilder.py b/swift/cli/ringbuilder.py index 7a2d10a0c0..983dbfde6c 100755 --- a/swift/cli/ringbuilder.py +++ b/swift/cli/ringbuilder.py @@ -27,6 +27,7 @@ from textwrap import wrap from time import time import optparse import math +from six.moves import input from swift.common import exceptions from swift.common.ring import RingBuilder, Ring @@ -188,8 +189,8 @@ def _set_weight_values(devs, weight): print('Matched more than one device:') for dev in devs: print(' %s' % format_device(dev)) - if raw_input('Are you sure you want to update the weight for ' - 'these %s devices? (y/N) ' % len(devs)) != 'y': + if input('Are you sure you want to update the weight for ' + 'these %s devices? (y/N) ' % len(devs)) != 'y': print('Aborting device modifications') exit(EXIT_ERROR) @@ -245,8 +246,8 @@ def _set_info_values(devs, change): print('Matched more than one device:') for dev in devs: print(' %s' % format_device(dev)) - if raw_input('Are you sure you want to update the info for ' - 'these %s devices? (y/N) ' % len(devs)) != 'y': + if input('Are you sure you want to update the info for ' + 'these %s devices? (y/N) ' % len(devs)) != 'y': print('Aborting device modifications') exit(EXIT_ERROR) @@ -732,8 +733,8 @@ swift-ring-builder search print('Matched more than one device:') for dev in devs: print(' %s' % format_device(dev)) - if raw_input('Are you sure you want to remove these %s ' - 'devices? (y/N) ' % len(devs)) != 'y': + if input('Are you sure you want to remove these %s ' + 'devices? (y/N) ' % len(devs)) != 'y': print('Aborting device removals') exit(EXIT_ERROR) diff --git a/test/unit/cli/test_recon.py b/test/unit/cli/test_recon.py index 345097c63f..3b0d11f889 100644 --- a/test/unit/cli/test_recon.py +++ b/test/unit/cli/test_recon.py @@ -554,11 +554,11 @@ class TestReconCommands(unittest.TestCase): mock.call('=' * 79), ] - with mock.patch('__builtin__.print') as mock_print: + with mock.patch('six.moves.builtins.print') as mock_print: cli.disk_usage([('127.0.0.1', 6010)]) mock_print.assert_has_calls(default_calls) - with mock.patch('__builtin__.print') as mock_print: + with mock.patch('six.moves.builtins.print') as mock_print: expected_calls = default_calls + [ mock.call('LOWEST 5'), mock.call('85.00% 127.0.0.1 sdc1'), @@ -568,7 +568,7 @@ class TestReconCommands(unittest.TestCase): cli.disk_usage([('127.0.0.1', 6010)], 0, 5) mock_print.assert_has_calls(expected_calls) - with mock.patch('__builtin__.print') as mock_print: + with mock.patch('six.moves.builtins.print') as mock_print: expected_calls = default_calls + [ mock.call('TOP 5'), mock.call('90.00% 127.0.0.1 sdb1'), @@ -578,7 +578,7 @@ class TestReconCommands(unittest.TestCase): cli.disk_usage([('127.0.0.1', 6010)], 5, 0) mock_print.assert_has_calls(expected_calls) - @mock.patch('__builtin__.print') + @mock.patch('six.moves.builtins.print') @mock.patch('time.time') def test_replication_check(self, mock_now, mock_print): now = 1430000000.0 @@ -633,7 +633,7 @@ class TestReconCommands(unittest.TestCase): # that is returned from the recon middleware, thus can't rely on it mock_print.assert_has_calls(default_calls, any_order=True) - @mock.patch('__builtin__.print') + @mock.patch('six.moves.builtins.print') @mock.patch('time.time') def test_load_check(self, mock_now, mock_print): now = 1430000000.0 @@ -672,7 +672,7 @@ class TestReconCommands(unittest.TestCase): # that is returned from the recon middleware, thus can't rely on it mock_print.assert_has_calls(default_calls, any_order=True) - @mock.patch('__builtin__.print') + @mock.patch('six.moves.builtins.print') @mock.patch('time.time') def test_time_check(self, mock_now, mock_print): now = 1430000000.0 @@ -704,7 +704,7 @@ class TestReconCommands(unittest.TestCase): # that is returned from the recon middleware, thus can't rely on it mock_print.assert_has_calls(default_calls, any_order=True) - @mock.patch('__builtin__.print') + @mock.patch('six.moves.builtins.print') @mock.patch('time.time') def test_time_check_mismatch(self, mock_now, mock_print): now = 1430000000.0 diff --git a/test/unit/common/ring/test_builder.py b/test/unit/common/ring/test_builder.py index d52faa60c8..2ca8a9b620 100644 --- a/test/unit/common/ring/test_builder.py +++ b/test/unit/common/ring/test_builder.py @@ -1552,7 +1552,7 @@ class TestRingBuilder(unittest.TestCase): self.assertEquals(loaded_rb.to_dict(), rb.to_dict()) self.assertEquals(loaded_rb.overload, 3.14159) - @mock.patch('__builtin__.open', autospec=True) + @mock.patch('six.moves.builtins.open', autospec=True) @mock.patch('swift.common.ring.builder.pickle.dump', autospec=True) def test_save(self, mock_pickle_dump, mock_open): mock_open.return_value = mock_fh = mock.MagicMock() diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index 5c88dff9c9..0a1b29f3a7 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -3446,7 +3446,7 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase): 'Content-Length': '0', } writer.put(metadata) - with mock.patch('__builtin__.open', mock_open): + with mock.patch('six.moves.builtins.open', mock_open): self.assertRaises(expected_exception, writer.commit, timestamp) @@ -3493,7 +3493,7 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase): 'Content-Length': '0', } writer.put(metadata) - with mock.patch('__builtin__.open', mock_open): + with mock.patch('six.moves.builtins.open', mock_open): self.assertRaises(expected_exception, writer.commit, timestamp)