diff --git a/test/unit/common/test_daemon.py b/test/unit/common/test_daemon.py index 6f37066a6e..078f84aebb 100644 --- a/test/unit/common/test_daemon.py +++ b/test/unit/common/test_daemon.py @@ -109,8 +109,8 @@ class TestRunDaemon(unittest.TestCase): def setUp(self): for patcher in [ - mock.patch.object(utils, 'HASH_PATH_PREFIX', 'startcap'), - mock.patch.object(utils, 'HASH_PATH_SUFFIX', 'endcap'), + mock.patch.object(utils, 'HASH_PATH_PREFIX', b'startcap'), + mock.patch.object(utils, 'HASH_PATH_SUFFIX', b'endcap'), mock.patch.object(utils, 'drop_privileges', lambda *args: None), mock.patch.object(utils, 'capture_stdio', lambda *args: None), ]: diff --git a/test/unit/common/test_internal_client.py b/test/unit/common/test_internal_client.py index 99adfe6ac6..22f88f25ac 100644 --- a/test/unit/common/test_internal_client.py +++ b/test/unit/common/test_internal_client.py @@ -226,7 +226,7 @@ class TestCompressingfileReader(unittest.TestCase): class TestInternalClient(unittest.TestCase): - @mock.patch('swift.common.utils.HASH_PATH_SUFFIX', new='endcap') + @mock.patch('swift.common.utils.HASH_PATH_SUFFIX', new=b'endcap') @with_tempdir def test_load_from_config(self, tempdir): conf_path = os.path.join(tempdir, 'interal_client.conf') diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 2a840be5f0..2ce8ab664a 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -70,7 +70,6 @@ class TestWSGI(unittest.TestCase): """Tests for swift.common.wsgi""" def setUp(self): - utils.HASH_PATH_PREFIX = 'startcap' if six.PY2: self._orig_parsetype = mimetools.Message.parsetype @@ -1818,7 +1817,6 @@ class TestPipelineWrapper(unittest.TestCase): @patch_policies -@mock.patch('swift.common.utils.HASH_PATH_SUFFIX', new='endcap') class TestPipelineModification(unittest.TestCase): def pipeline_modules(self, app): # This is rather brittle; it'll break if a middleware stores its app diff --git a/test/unit/container/test_sync.py b/test/unit/container/test_sync.py index 5c4cc8670a..4fb42fa210 100644 --- a/test/unit/container/test_sync.py +++ b/test/unit/container/test_sync.py @@ -31,8 +31,8 @@ from swift.common.storage_policy import StoragePolicy import test from test.unit import patch_policies, with_tempdir -utils.HASH_PATH_SUFFIX = 'endcap' -utils.HASH_PATH_PREFIX = 'endcap' +utils.HASH_PATH_SUFFIX = b'endcap' +utils.HASH_PATH_PREFIX = b'endcap' class FakeRing(object): diff --git a/test/unit/container/test_updater.py b/test/unit/container/test_updater.py index 4841c57db6..c8150f5fe8 100644 --- a/test/unit/container/test_updater.py +++ b/test/unit/container/test_updater.py @@ -37,8 +37,8 @@ from test import listen_zero class TestContainerUpdater(unittest.TestCase): def setUp(self): - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = 'startcap' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'startcap' self.testdir = os.path.join(mkdtemp(), 'tmp_test_container_updater') rmtree(self.testdir, ignore_errors=1) os.mkdir(self.testdir) diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index e4ad4c0e7a..161e85a8cc 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -147,8 +147,8 @@ class TestDiskFileModuleMethods(unittest.TestCase): def setUp(self): skip_if_no_xattrs() - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'' # Setup a test ring per policy (stolen from common/test_ring.py) self.testdir = tempfile.mkdtemp() self.devices = os.path.join(self.testdir, 'node') diff --git a/test/unit/obj/test_reconstructor.py b/test/unit/obj/test_reconstructor.py index 4e664c23c1..6c067a3d44 100644 --- a/test/unit/obj/test_reconstructor.py +++ b/test/unit/obj/test_reconstructor.py @@ -154,8 +154,8 @@ class TestGlobalSetupObjectReconstructor(unittest.TestCase): _create_test_rings(self.testdir) POLICIES[0].object_ring = ring.Ring(self.testdir, ring_name='object') POLICIES[1].object_ring = ring.Ring(self.testdir, ring_name='object-1') - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'' self.devices = os.path.join(self.testdir, 'node') os.makedirs(self.devices) os.mkdir(os.path.join(self.devices, 'sda1')) diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py index e54cc94c95..acc664aab3 100644 --- a/test/unit/obj/test_replicator.py +++ b/test/unit/obj/test_replicator.py @@ -224,8 +224,8 @@ class TestObjectReplicator(unittest.TestCase): def setUp(self): skip_if_no_xattrs() - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'' # recon cache path self.recon_cache = tempfile.mkdtemp() rmtree(self.recon_cache, ignore_errors=1) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index e3e0d66dce..f3ac45c619 100644 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -139,8 +139,8 @@ class TestObjectController(unittest.TestCase): def setUp(self): """Set up for testing swift.object.server.ObjectController""" skip_if_no_xattrs() - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = 'startcap' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'startcap' self.tmpdir = mkdtemp() self.testdir = os.path.join(self.tmpdir, 'tmp_test_object_server_ObjectController') @@ -958,7 +958,7 @@ class TestObjectController(unittest.TestCase): headers=put_headers, body='test') with mock.patch('swift.obj.server.http_connect', fake_http_connect), \ - mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \ + mock.patch('swift.common.utils.HASH_PATH_PREFIX', b''), \ fake_spawn(): resp = req.get_response(self.object_controller) @@ -1002,7 +1002,7 @@ class TestObjectController(unittest.TestCase): headers=post_headers) with mock.patch('swift.obj.server.http_connect', fake_http_connect), \ - mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \ + mock.patch('swift.common.utils.HASH_PATH_PREFIX', b''), \ fake_spawn(): resp = req.get_response(self.object_controller) @@ -1112,7 +1112,7 @@ class TestObjectController(unittest.TestCase): 'X-Backend-Redirect-Timestamp': next(self.ts).internal} with mocked_http_conn(301, headers=[resp_headers]) as conn, \ - mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''),\ + mock.patch('swift.common.utils.HASH_PATH_PREFIX', b''),\ fake_spawn(): resp = req.get_response(self.object_controller) @@ -5088,7 +5088,7 @@ class TestObjectController(unittest.TestCase): policy = random.choice(list(POLICIES)) self._stage_tmp_dir(policy) _prefix = utils.HASH_PATH_PREFIX - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_PREFIX = b'' def fake_http_connect(*args): raise Exception('test') @@ -5119,7 +5119,7 @@ class TestObjectController(unittest.TestCase): policy = random.choice(list(POLICIES)) self._stage_tmp_dir(policy) _prefix = utils.HASH_PATH_PREFIX - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_PREFIX = b'' def fake_http_connect(status): @@ -5164,7 +5164,7 @@ class TestObjectController(unittest.TestCase): def test_async_update_does_not_save_on_2xx(self): _prefix = utils.HASH_PATH_PREFIX - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_PREFIX = b'' def fake_http_connect(status): @@ -5200,7 +5200,7 @@ class TestObjectController(unittest.TestCase): policy = random.choice(list(POLICIES)) self._stage_tmp_dir(policy) _prefix = utils.HASH_PATH_PREFIX - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_PREFIX = b'' def fake_http_connect(): diff --git a/test/unit/obj/test_ssync_receiver.py b/test/unit/obj/test_ssync_receiver.py index 9ad5b619dd..88ad9bfe19 100644 --- a/test/unit/obj/test_ssync_receiver.py +++ b/test/unit/obj/test_ssync_receiver.py @@ -44,8 +44,8 @@ class TestReceiver(unittest.TestCase): def setUp(self): skip_if_no_xattrs() - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = 'startcap' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'startcap' # Not sure why the test.unit stuff isn't taking effect here; so I'm # reinforcing it. self.testdir = os.path.join( diff --git a/test/unit/obj/test_updater.py b/test/unit/obj/test_updater.py index 5ee6d9bc13..511bcb0b37 100644 --- a/test/unit/obj/test_updater.py +++ b/test/unit/obj/test_updater.py @@ -68,8 +68,8 @@ _mocked_policies = [StoragePolicy(0, 'zero', False), class TestObjectUpdater(unittest.TestCase): def setUp(self): - utils.HASH_PATH_SUFFIX = 'endcap' - utils.HASH_PATH_PREFIX = '' + utils.HASH_PATH_SUFFIX = b'endcap' + utils.HASH_PATH_PREFIX = b'' self.testdir = mkdtemp() ring_file = os.path.join(self.testdir, 'container.ring.gz') with closing(GzipFile(ring_file, 'wb')) as f: diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 22b312fbbe..bcc5a5bed1 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -1223,7 +1223,7 @@ class TestProxyServerLoading(unittest.TestCase): def setUp(self): self._orig_hash_suffix = utils.HASH_PATH_SUFFIX - utils.HASH_PATH_SUFFIX = 'endcap' + utils.HASH_PATH_SUFFIX = b'endcap' self.tempdir = mkdtemp() def tearDown(self):