diff --git a/bin/swift-account-audit b/bin/swift-account-audit index 93c8c8c044..703eec9953 100755 --- a/bin/swift-account-audit +++ b/bin/swift-account-audit @@ -20,7 +20,7 @@ from hashlib import md5 import getopt from itertools import chain -import simplejson +import json from eventlet.greenpool import GreenPool from eventlet.event import Event from six.moves.urllib.parse import quote @@ -176,7 +176,7 @@ class Auditor(object): break if node['id'] not in responses: responses[node['id']] = dict(resp.getheaders()) - results = simplejson.loads(resp.read()) + results = json.loads(resp.read()) except Exception: self.container_exceptions += 1 consistent = False @@ -249,7 +249,7 @@ class Auditor(object): " from %ss:%ss" % (account, node['ip'], node['device'])) break - results = simplejson.loads(resp.read()) + results = json.loads(resp.read()) except Exception: self.account_exceptions += 1 consistent = False diff --git a/bin/swift-dispersion-report b/bin/swift-dispersion-report index b53d58e1a7..a1b5fdaab0 100755 --- a/bin/swift-dispersion-report +++ b/bin/swift-dispersion-report @@ -14,15 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from collections import defaultdict from six.moves.configparser import ConfigParser from optparse import OptionParser from sys import exit, stdout, stderr from time import time -try: - import simplejson as json -except ImportError: - import json from eventlet import GreenPool, hubs, patcher, Timeout from eventlet.pools import Pool diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index d4b9016b88..1a282983b6 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -39,7 +39,7 @@ Installing dependencies sudo apt-get install curl gcc memcached rsync sqlite3 xfsprogs \ git-core libffi-dev python-setuptools sudo apt-get install python-coverage python-dev python-nose \ - python-simplejson python-xattr python-eventlet \ + python-xattr python-eventlet \ python-greenlet python-pastedeploy \ python-netifaces python-pip python-dnspython \ python-mock @@ -50,14 +50,14 @@ Installing dependencies sudo yum install curl gcc memcached rsync sqlite xfsprogs git-core \ libffi-devel xinetd python-setuptools \ python-coverage python-devel python-nose \ - python-simplejson pyxattr python-eventlet \ + pyxattr python-eventlet \ python-greenlet python-paste-deploy \ python-netifaces python-pip python-dns \ python-mock Note: This installs necessary system dependencies and *most* of the python dependencies. Later in the process setuptools/distribute or pip will install - and/or upgrade packages. + and/or upgrade packages. Next, choose either :ref:`partition-section` or :ref:`loopback-section`. diff --git a/requirements.txt b/requirements.txt index bac2dd236b..afbbe17b05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ eventlet>=0.16.1,!=0.17.0 greenlet>=0.3.1 netifaces>=0.5,!=0.10.0,!=0.10.1 pastedeploy>=1.3.3 -simplejson>=2.0.9 six>=1.9.0 xattr>=0.4 PyECLib==1.0.7 # BSD diff --git a/swift/account/utils.py b/swift/account/utils.py index d9b2b77396..2baade9c55 100644 --- a/swift/account/utils.py +++ b/swift/account/utils.py @@ -13,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import time from xml.sax import saxutils from swift.common.swob import HTTPOk, HTTPNoContent -from swift.common.utils import json, Timestamp +from swift.common.utils import Timestamp from swift.common.storage_policy import POLICIES diff --git a/swift/common/db.py b/swift/common/db.py index ca6b12d80f..cead803375 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -17,6 +17,7 @@ from contextlib import contextmanager, closing import hashlib +import json import logging import os from uuid import uuid4 @@ -32,7 +33,7 @@ from eventlet import sleep, Timeout import sqlite3 from swift.common.constraints import MAX_META_COUNT, MAX_META_OVERALL_SIZE -from swift.common.utils import json, Timestamp, renamer, \ +from swift.common.utils import Timestamp, renamer, \ mkdirs, lock_parent_directory, fallocate from swift.common.exceptions import LockTimeout from swift.common.swob import HTTPBadRequest diff --git a/swift/common/direct_client.py b/swift/common/direct_client.py index b262ebce62..2f7a1fa675 100644 --- a/swift/common/direct_client.py +++ b/swift/common/direct_client.py @@ -18,6 +18,7 @@ Internal client library for making calls directly to the servers rather than through the proxy. """ +import json import os import socket from time import time @@ -34,11 +35,6 @@ from swift.common.http import HTTP_NO_CONTENT, HTTP_INSUFFICIENT_STORAGE, \ from swift.common.swob import HeaderKeyDict from swift.common.utils import quote -try: - import simplejson as json -except ImportError: - import json - class DirectClientException(ClientException): diff --git a/swift/common/memcached.py b/swift/common/memcached.py index f3d0eae5d6..5dc9e0b0fc 100644 --- a/swift/common/memcached.py +++ b/swift/common/memcached.py @@ -45,6 +45,7 @@ http://github.com/memcached/memcached/blob/1.4.2/doc/protocol.txt """ import six.moves.cPickle as pickle +import json import logging import time from bisect import bisect @@ -56,7 +57,6 @@ from eventlet.pools import Pool from eventlet import Timeout from six.moves import range -from swift.common.utils import json DEFAULT_MEMCACHED_PORT = 11211 diff --git a/swift/common/middleware/acl.py b/swift/common/middleware/acl.py index 2aed09dd2c..ea2f392cae 100644 --- a/swift/common/middleware/acl.py +++ b/swift/common/middleware/acl.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from swift.common.utils import urlparse, json +import json + +from swift.common.utils import urlparse def clean_acl(name, value): diff --git a/swift/common/middleware/bulk.py b/swift/common/middleware/bulk.py index aa135d8eb5..7fb227b457 100644 --- a/swift/common/middleware/bulk.py +++ b/swift/common/middleware/bulk.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from six.moves.urllib.parse import quote, unquote import tarfile from xml.sax import saxutils @@ -23,7 +24,7 @@ from swift.common.swob import Request, HTTPBadGateway, \ HTTPCreated, HTTPBadRequest, HTTPNotFound, HTTPUnauthorized, HTTPOk, \ HTTPPreconditionFailed, HTTPRequestEntityTooLarge, HTTPNotAcceptable, \ HTTPLengthRequired, HTTPException, HTTPServerError, wsgify -from swift.common.utils import json, get_logger, register_swift_info +from swift.common.utils import get_logger, register_swift_info from swift.common import constraints from swift.common.http import HTTP_UNAUTHORIZED, HTTP_NOT_FOUND, HTTP_CONFLICT @@ -32,7 +33,7 @@ class CreateContainerError(Exception): def __init__(self, msg, status_int, status): self.status_int = status_int self.status = status - Exception.__init__(self, msg) + super(CreateContainerError, self).__init__(msg) ACCEPTABLE_FORMATS = ['text/plain', 'application/json', 'application/xml', diff --git a/swift/common/middleware/dlo.py b/swift/common/middleware/dlo.py index b02aa7b2b9..ebdd639504 100644 --- a/swift/common/middleware/dlo.py +++ b/swift/common/middleware/dlo.py @@ -114,6 +114,7 @@ Here's an example using ``curl`` with tiny 1-byte segments:: http:///container/myobject """ +import json import os import six @@ -126,7 +127,7 @@ from swift.common.exceptions import ListingIterError, SegmentError from swift.common.http import is_success from swift.common.swob import Request, Response, \ HTTPRequestedRangeNotSatisfiable, HTTPBadRequest, HTTPConflict -from swift.common.utils import get_logger, json, \ +from swift.common.utils import get_logger, \ RateLimitedIterator, read_conf_dir, quote, close_if_possible, \ closing_if_possible from swift.common.request_helpers import SegmentedIterable diff --git a/swift/common/middleware/list_endpoints.py b/swift/common/middleware/list_endpoints.py index fb41bb6dd3..2e55d45fac 100644 --- a/swift/common/middleware/list_endpoints.py +++ b/swift/common/middleware/list_endpoints.py @@ -78,11 +78,12 @@ with this middleware enabled should not be open to an untrusted environment (everyone can query the locality data using this middleware). """ +import json from six.moves.urllib.parse import quote, unquote from swift.common.ring import Ring -from swift.common.utils import json, get_logger, split_path +from swift.common.utils import get_logger, split_path from swift.common.swob import Request, Response from swift.common.swob import HTTPBadRequest, HTTPMethodNotAllowed from swift.common.storage_policy import POLICIES diff --git a/swift/common/middleware/recon.py b/swift/common/middleware/recon.py index 3014962f21..b73823888a 100644 --- a/swift/common/middleware/recon.py +++ b/swift/common/middleware/recon.py @@ -14,6 +14,7 @@ # limitations under the License. import errno +import json import os import time from swift import gettext_ as _ @@ -21,7 +22,7 @@ from swift import gettext_ as _ from swift import __version__ as swiftver from swift.common.storage_policy import POLICIES from swift.common.swob import Request, Response -from swift.common.utils import get_logger, config_true_value, json, \ +from swift.common.utils import get_logger, config_true_value, \ SWIFT_CONF_FILE from swift.common.constraints import check_mount from resource import getpagesize diff --git a/swift/common/middleware/slo.py b/swift/common/middleware/slo.py index f46f6b7d54..899632a1f0 100644 --- a/swift/common/middleware/slo.py +++ b/swift/common/middleware/slo.py @@ -197,6 +197,7 @@ metadata which can be used for stats purposes. from six.moves import range from datetime import datetime +import json import mimetypes import re import six @@ -208,7 +209,7 @@ from swift.common.swob import Request, HTTPBadRequest, HTTPServerError, \ HTTPOk, HTTPPreconditionFailed, HTTPException, HTTPNotFound, \ HTTPUnauthorized, HTTPConflict, HTTPRequestedRangeNotSatisfiable,\ Response, Range -from swift.common.utils import json, get_logger, config_true_value, \ +from swift.common.utils import get_logger, config_true_value, \ get_valid_utf8_str, override_bytes_from_content_type, split_path, \ register_swift_info, RateLimitedIterator, quote, close_if_possible, \ closing_if_possible diff --git a/swift/common/middleware/versioned_writes.py b/swift/common/middleware/versioned_writes.py index 4c2f8a7d31..5a775d65bd 100644 --- a/swift/common/middleware/versioned_writes.py +++ b/swift/common/middleware/versioned_writes.py @@ -113,10 +113,11 @@ Disable versioning from a container (x is any value except empty):: -H "X-Remove-Versions-Location: x" http:///container """ +import json import six from six.moves.urllib.parse import quote, unquote import time -from swift.common.utils import get_logger, Timestamp, json, \ +from swift.common.utils import get_logger, Timestamp, \ register_swift_info, config_true_value from swift.common.request_helpers import get_sys_meta_prefix from swift.common.wsgi import WSGIContext, make_pre_authed_request diff --git a/swift/common/ring/ring.py b/swift/common/ring/ring.py index c62015fa3d..e00b0db3a9 100644 --- a/swift/common/ring/ring.py +++ b/swift/common/ring/ring.py @@ -16,6 +16,7 @@ import array import six.moves.cPickle as pickle import inspect +import json from collections import defaultdict from gzip import GzipFile from os.path import getmtime @@ -29,7 +30,7 @@ from tempfile import NamedTemporaryFile from six.moves import range -from swift.common.utils import hash_path, validate_configuration, json +from swift.common.utils import hash_path, validate_configuration from swift.common.ring.utils import tiers_for_dev diff --git a/swift/common/utils.py b/swift/common/utils.py index 85ac3df987..74a2134624 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -21,6 +21,7 @@ import errno import fcntl import grp import hmac +import json import operator import os import pwd @@ -39,10 +40,6 @@ import ctypes.util from optparse import OptionParser from tempfile import mkstemp, NamedTemporaryFile -try: - import simplejson as json -except ImportError: - import json import glob import itertools import stat diff --git a/swift/container/replicator.py b/swift/container/replicator.py index b9f9a3b2b0..810c7db600 100644 --- a/swift/container/replicator.py +++ b/swift/container/replicator.py @@ -15,6 +15,7 @@ import os import itertools +import json import time from collections import defaultdict from eventlet import Timeout @@ -28,7 +29,7 @@ from swift.common.storage_policy import POLICIES from swift.common.exceptions import DeviceUnavailable from swift.common.http import is_success from swift.common.db import DatabaseAlreadyExists -from swift.common.utils import (json, Timestamp, hash_path, +from swift.common.utils import (Timestamp, hash_path, storage_directory, quorum_size) diff --git a/swift/container/server.py b/swift/container/server.py index 821ab9b188..4f00bbca8f 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os import time import traceback @@ -30,7 +31,7 @@ from swift.common.request_helpers import get_param, get_listing_content_type, \ split_and_validate_path, is_sys_or_user_meta from swift.common.utils import get_logger, hash_path, public, \ Timestamp, storage_directory, validate_sync_to, \ - config_true_value, json, timing_stats, replication, \ + config_true_value, timing_stats, replication, \ override_bytes_from_content_type, get_log_line from swift.common.constraints import check_mount, valid_timestamp, check_utf8 from swift.common import constraints diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index 4875bb2520..38fef209e1 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os import sys import time @@ -24,7 +25,7 @@ from eventlet import Timeout from swift.obj import diskfile from swift.common.utils import get_logger, ratelimit_sleep, dump_recon_cache, \ - list_from_csv, json, listdir + list_from_csv, listdir from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist from swift.common.daemon import Daemon diff --git a/swift/proxy/controllers/info.py b/swift/proxy/controllers/info.py index 5580da0183..57f3c1b90f 100644 --- a/swift/proxy/controllers/info.py +++ b/swift/proxy/controllers/info.py @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from time import time -from swift.common.utils import public, get_hmac, get_swift_info, json, \ +from swift.common.utils import public, get_hmac, get_swift_info, \ streq_const_time from swift.proxy.controllers.base import Controller, delay_denial from swift.common.swob import HTTPOk, HTTPForbidden, HTTPUnauthorized diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 87d3b5241c..b58ba4ba3c 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -29,6 +29,7 @@ from six.moves.urllib.parse import unquote, quote import collections import itertools +import json import mimetypes import time import math @@ -43,7 +44,7 @@ from eventlet.timeout import Timeout from swift.common.utils import ( clean_content_type, config_true_value, ContextPool, csv_append, - GreenAsyncPile, GreenthreadSafeIterator, json, Timestamp, + GreenAsyncPile, GreenthreadSafeIterator, Timestamp, normalize_delete_at_timestamp, public, get_expirer_container, document_iters_to_http_response_body, parse_content_range, quorum_size, reiterate, close_if_possible) diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 68dcbea017..63090e5b96 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -14,12 +14,12 @@ # limitations under the License. import hashlib +import json import os import random import socket import time -import simplejson as json from nose import SkipTest from xml.dom import minidom diff --git a/test/unit/account/test_server.py b/test/unit/account/test_server.py index e835b37599..db4f09cc1f 100644 --- a/test/unit/account/test_server.py +++ b/test/unit/account/test_server.py @@ -24,7 +24,7 @@ from test.unit import FakeLogger import itertools import random -import simplejson +import json from six import BytesIO from six import StringIO import xml.dom.minidom @@ -806,7 +806,7 @@ class TestAccountController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(simplejson.loads(resp.body), + self.assertEqual(json.loads(resp.body), [{'count': 0, 'bytes': 0, 'name': 'c1'}, {'count': 0, 'bytes': 0, 'name': 'c2'}]) req = Request.blank('/sda1/p/a/c1', environ={'REQUEST_METHOD': 'PUT'}, @@ -827,7 +827,7 @@ class TestAccountController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(simplejson.loads(resp.body), + self.assertEqual(json.loads(resp.body), [{'count': 1, 'bytes': 2, 'name': 'c1'}, {'count': 3, 'bytes': 4, 'name': 'c2'}]) self.assertEqual(resp.content_type, 'application/json') @@ -1031,7 +1031,7 @@ class TestAccountController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(simplejson.loads(resp.body), + self.assertEqual(json.loads(resp.body), [{'count': 2, 'bytes': 3, 'name': 'c0'}, {'count': 2, 'bytes': 3, 'name': 'c1'}, {'count': 2, 'bytes': 3, 'name': 'c2'}]) @@ -1039,7 +1039,7 @@ class TestAccountController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(simplejson.loads(resp.body), + self.assertEqual(json.loads(resp.body), [{'count': 2, 'bytes': 3, 'name': 'c3'}, {'count': 2, 'bytes': 3, 'name': 'c4'}]) @@ -1152,7 +1152,7 @@ class TestAccountController(unittest.TestCase): req.accept = 'application/*' resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(len(simplejson.loads(resp.body)), 1) + self.assertEqual(len(json.loads(resp.body)), 1) def test_GET_accept_json(self): req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', @@ -1169,7 +1169,7 @@ class TestAccountController(unittest.TestCase): req.accept = 'application/json' resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(len(simplejson.loads(resp.body)), 1) + self.assertEqual(len(json.loads(resp.body)), 1) def test_GET_accept_xml(self): req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', @@ -1305,14 +1305,14 @@ class TestAccountController(unittest.TestCase): resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) self.assertEqual([n.get('name', 's:' + n.get('subdir', 'error')) - for n in simplejson.loads(resp.body)], ['s:sub.']) + for n in json.loads(resp.body)], ['s:sub.']) req = Request.blank('/sda1/p/a?prefix=sub.&delimiter=.&format=json', environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) self.assertEqual( [n.get('name', 's:' + n.get('subdir', 'error')) - for n in simplejson.loads(resp.body)], + for n in json.loads(resp.body)], ['sub.0', 's:sub.0.', 'sub.1', 's:sub.1.', 'sub.2', 's:sub.2.']) req = Request.blank('/sda1/p/a?prefix=sub.1.&delimiter=.&format=json', environ={'REQUEST_METHOD': 'GET'}) @@ -1320,7 +1320,7 @@ class TestAccountController(unittest.TestCase): self.assertEqual(resp.status_int, 200) self.assertEqual( [n.get('name', 's:' + n.get('subdir', 'error')) - for n in simplejson.loads(resp.body)], + for n in json.loads(resp.body)], ['sub.1.0', 'sub.1.1', 'sub.1.2']) def test_GET_prefix_delimiter_xml(self): diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index a5918918d3..839f4f7d2a 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -17,6 +17,7 @@ from six.moves import range import hashlib +import json import time import unittest from mock import patch @@ -25,17 +26,17 @@ from swift.common import swob, utils from swift.common.exceptions import ListingIterError, SegmentError from swift.common.middleware import slo from swift.common.swob import Request, Response, HTTPException -from swift.common.utils import quote, json, closing_if_possible +from swift.common.utils import quote, closing_if_possible from test.unit.common.middleware.helpers import FakeSwift test_xml_data = ''' - -/cont/object -etagoftheobjectsegment -100 - + + /cont/object + etagoftheobjectsegment + 100 + ''' test_json_data = json.dumps([{'path': '/cont/object', diff --git a/test/unit/common/test_bufferedhttp.py b/test/unit/common/test_bufferedhttp.py index aefb54a1cb..7029511d83 100644 --- a/test/unit/common/test_bufferedhttp.py +++ b/test/unit/common/test_bufferedhttp.py @@ -111,11 +111,6 @@ class TestBufferedHTTP(unittest.TestCase): bufferedhttp.HTTPSConnection = origHTTPSConnection def test_unicode_values(self): - # simplejson may decode the ring devices as str or unicode - # depending on whether speedups is installed and/or the values are - # non-ascii. Verify all types are tolerated in combination with - # whatever type path might be and possible encoded non-ascii in - # a header value. with mock.patch('swift.common.bufferedhttp.HTTPSConnection', MockHTTPSConnection): for dev in ('sda', u'sda', u'sdá', u'sdá'.encode('utf-8')): diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index c844419ae4..925e71438a 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -23,7 +23,7 @@ from shutil import rmtree, copy from uuid import uuid4 import six.moves.cPickle as pickle -import simplejson +import json import sqlite3 import itertools import time @@ -39,7 +39,7 @@ from swift.common.constraints import \ from swift.common.db import chexor, dict_factory, get_db_connection, \ DatabaseBroker, DatabaseConnectionError, DatabaseAlreadyExists, \ GreenDBConnection, PICKLE_PROTOCOL -from swift.common.utils import normalize_timestamp, mkdirs, json, Timestamp +from swift.common.utils import normalize_timestamp, mkdirs, Timestamp from swift.common.exceptions import LockTimeout from swift.common.swob import HTTPException @@ -963,7 +963,7 @@ class TestDatabaseBroker(unittest.TestCase): broker.db_contains_type = 'test' broker_creation = normalize_timestamp(1) broker_uuid = str(uuid4()) - broker_metadata = metadata and simplejson.dumps( + broker_metadata = metadata and json.dumps( {'Test': ('Value', normalize_timestamp(1))}) or '' def _initialize(conn, put_timestamp, **kwargs): diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index 5ea1f3d631..422c0c56b8 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -25,7 +25,7 @@ from mock import patch, call from shutil import rmtree, copy from tempfile import mkdtemp, NamedTemporaryFile import mock -import simplejson +import json from swift.container.backend import DATADIR from swift.common import db_replicator @@ -1207,7 +1207,7 @@ class TestReplToNode(unittest.TestCase): def test_repl_to_node_usync_success(self): rinfo = {"id": 3, "point": -1, "max_row": 10, "hash": "c"} - self.http = ReplHttp(simplejson.dumps(rinfo)) + self.http = ReplHttp(json.dumps(rinfo)) local_sync = self.broker.get_sync() self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) @@ -1218,7 +1218,7 @@ class TestReplToNode(unittest.TestCase): def test_repl_to_node_rsync_success(self): rinfo = {"id": 3, "point": -1, "max_row": 9, "hash": "c"} - self.http = ReplHttp(simplejson.dumps(rinfo)) + self.http = ReplHttp(json.dumps(rinfo)) self.broker.get_sync() self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) @@ -1235,7 +1235,7 @@ class TestReplToNode(unittest.TestCase): def test_repl_to_node_already_in_sync(self): rinfo = {"id": 3, "point": -1, "max_row": 20, "hash": "b"} - self.http = ReplHttp(simplejson.dumps(rinfo)) + self.http = ReplHttp(json.dumps(rinfo)) self.broker.get_sync() self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) @@ -1282,7 +1282,7 @@ class TestReplToNode(unittest.TestCase): rinfo['max_row'] = r self.fake_info['max_row'] = l self.replicator._usync_db = mock.Mock(return_value=True) - self.http = ReplHttp(simplejson.dumps(rinfo)) + self.http = ReplHttp(json.dumps(rinfo)) local_sync = self.broker.get_sync() self.assertEqual(self.replicator._repl_to_node( self.fake_node, self.broker, '0', self.fake_info), True) diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py index b7d2c03130..fb414207d5 100644 --- a/test/unit/container/test_server.py +++ b/test/unit/container/test_server.py @@ -28,7 +28,7 @@ import time import random from eventlet import spawn, Timeout, listen -import simplejson +import json import six from six import BytesIO from six import StringIO @@ -40,8 +40,7 @@ import swift.container from swift.container import server as container_server from swift.common import constraints from swift.common.utils import (Timestamp, mkdirs, public, replication, - storage_directory, lock_parent_directory, - json) + storage_directory, lock_parent_directory) from test.unit import fake_http_connect, debug_logger from swift.common.storage_policy import (POLICIES, StoragePolicy) from swift.common.request_helpers import get_sys_meta_prefix @@ -1691,7 +1690,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.status_int, 200) - self.assertEqual(simplejson.loads(resp.body), []) + self.assertEqual(json.loads(resp.body), []) # fill the container for i in range(3): req = Request.blank( @@ -1726,7 +1725,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.content_type, 'application/json') - self.assertEqual(simplejson.loads(resp.body), json_body) + self.assertEqual(json.loads(resp.body), json_body) self.assertEqual(resp.charset, 'utf-8') req = Request.blank( @@ -1743,7 +1742,7 @@ class TestContainerController(unittest.TestCase): req.accept = accept resp = req.get_response(self.controller) self.assertEqual( - simplejson.loads(resp.body), json_body, + json.loads(resp.body), json_body, 'Invalid body for Accept: %s' % accept) self.assertEqual( resp.content_type, 'application/json', @@ -1873,7 +1872,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual(resp.content_type, 'application/json') - self.assertEqual(simplejson.loads(resp.body), json_body) + self.assertEqual(json.loads(resp.body), json_body) self.assertEqual(resp.charset, 'utf-8') def test_GET_xml(self): @@ -2001,7 +2000,7 @@ class TestContainerController(unittest.TestCase): req = Request.blank('/sda1/p/a/c?format=json', environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) - result = [x['content_type'] for x in simplejson.loads(resp.body)] + result = [x['content_type'] for x in json.loads(resp.body)] self.assertEqual(result, [u'\u2603', 'text/plain;charset="utf-8"']) def test_GET_accept_not_valid(self): @@ -2089,7 +2088,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual( - simplejson.loads(resp.body), + json.loads(resp.body), [{"subdir": "US-OK-"}, {"subdir": "US-TX-"}, {"subdir": "US-UT-"}]) @@ -2170,7 +2169,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = req.get_response(self.controller) self.assertEqual( - simplejson.loads(resp.body), + json.loads(resp.body), [{"name": "US/OK", "hash": "x", "bytes": 0, "content_type": "text/plain", "last_modified": "1970-01-01T00:00:01.000000"}, diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py index 204a9b88f0..f865954fe8 100644 --- a/test/unit/proxy/controllers/test_base.py +++ b/test/unit/proxy/controllers/test_base.py @@ -342,7 +342,6 @@ class TestFuncs(unittest.TestCase): def test_get_container_info_cache(self): cache_stub = { 'status': 404, 'bytes': 3333, 'object_count': 10, - # simplejson sometimes hands back strings, sometimes unicodes 'versions': u"\u1F4A9"} req = Request.blank("/v1/account/cont", environ={'swift.cache': FakeCache(cache_stub)}) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index c51360d18c..c3e8fc6b20 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -17,6 +17,7 @@ from __future__ import print_function import email.parser import logging +import json import math import os import pickle @@ -47,7 +48,7 @@ from six import StringIO from six.moves import range from six.moves.urllib.parse import quote -from swift.common.utils import hash_path, json, storage_directory, \ +from swift.common.utils import hash_path, storage_directory, \ parse_content_type, parse_mime_headers, \ iter_multipart_mime_documents, public