Merge "test/unit: Replace python print operator with print function (pep H233, py33)"
This commit is contained in:
commit
f644eaef7d
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
""" Swift tests """
|
""" Swift tests """
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
@ -572,8 +573,8 @@ class FakeLogger(logging.Logger, object):
|
|||||||
try:
|
try:
|
||||||
line = record.getMessage()
|
line = record.getMessage()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print 'WARNING: unable to format log message %r %% %r' % (
|
print('WARNING: unable to format log message %r %% %r' % (
|
||||||
record.msg, record.args)
|
record.msg, record.args))
|
||||||
raise
|
raise
|
||||||
self.lines_dict[record.levelname.lower()].append(line)
|
self.lines_dict[record.levelname.lower()].append(line)
|
||||||
|
|
||||||
@ -597,7 +598,7 @@ class DebugLogger(FakeLogger):
|
|||||||
|
|
||||||
def handle(self, record):
|
def handle(self, record):
|
||||||
self._handle(record)
|
self._handle(record)
|
||||||
print self.formatter.format(record)
|
print(self.formatter.format(record))
|
||||||
|
|
||||||
|
|
||||||
class DebugLogAdapter(utils.LogAdapter):
|
class DebugLogAdapter(utils.LogAdapter):
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import unittest
|
import unittest
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import os
|
import os
|
||||||
@ -1304,7 +1305,7 @@ def attach_fake_replication_rpc(rpc, replicate_hook=None):
|
|||||||
self.host = node['replication_ip']
|
self.host = node['replication_ip']
|
||||||
|
|
||||||
def replicate(self, op, *sync_args):
|
def replicate(self, op, *sync_args):
|
||||||
print 'REPLICATE: %s, %s, %r' % (self.path, op, sync_args)
|
print('REPLICATE: %s, %s, %r' % (self.path, op, sync_args))
|
||||||
replicate_args = self.path.lstrip('/').split('/')
|
replicate_args = self.path.lstrip('/').split('/')
|
||||||
args = [op] + list(sync_args)
|
args = [op] + list(sync_args)
|
||||||
swob_response = rpc.dispatch(replicate_args, args)
|
swob_response = rpc.dispatch(replicate_args, args)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# implied.
|
# implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
from __future__ import print_function
|
||||||
import unittest
|
import unittest
|
||||||
from test.unit import temptree
|
from test.unit import temptree
|
||||||
|
|
||||||
@ -1188,9 +1188,9 @@ class TestServer(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def fail(self):
|
def fail(self):
|
||||||
print >>self._stdout, 'mock process started'
|
print('mock process started', file=self._stdout)
|
||||||
sleep(self.delay) # perform setup processing
|
sleep(self.delay) # perform setup processing
|
||||||
print >>self._stdout, 'mock process failed to start'
|
print('mock process failed to start', file=self._stdout)
|
||||||
self.close_stdout()
|
self.close_stdout()
|
||||||
|
|
||||||
def poll(self):
|
def poll(self):
|
||||||
@ -1198,12 +1198,12 @@ class TestServer(unittest.TestCase):
|
|||||||
return self.returncode or None
|
return self.returncode or None
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print >>self._stdout, 'mock process started'
|
print('mock process started', file=self._stdout)
|
||||||
sleep(self.delay) # perform setup processing
|
sleep(self.delay) # perform setup processing
|
||||||
print >>self._stdout, 'setup complete!'
|
print('setup complete!', file=self._stdout)
|
||||||
self.close_stdout()
|
self.close_stdout()
|
||||||
sleep(self.delay) # do some more processing
|
sleep(self.delay) # do some more processing
|
||||||
print >>self._stdout, 'mock process finished'
|
print('mock process finished', file=self._stdout)
|
||||||
self.finished = True
|
self.finished = True
|
||||||
|
|
||||||
class MockTime(object):
|
class MockTime(object):
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Tests for swift.common.utils"""
|
"""Tests for swift.common.utils"""
|
||||||
|
from __future__ import print_function
|
||||||
from test.unit import temptree
|
from test.unit import temptree
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
@ -1047,22 +1047,22 @@ class TestUtils(unittest.TestCase):
|
|||||||
lfo_stdout = utils.LoggerFileObject(logger)
|
lfo_stdout = utils.LoggerFileObject(logger)
|
||||||
lfo_stderr = utils.LoggerFileObject(logger)
|
lfo_stderr = utils.LoggerFileObject(logger)
|
||||||
lfo_stderr = utils.LoggerFileObject(logger, 'STDERR')
|
lfo_stderr = utils.LoggerFileObject(logger, 'STDERR')
|
||||||
print 'test1'
|
print('test1')
|
||||||
self.assertEquals(sio.getvalue(), '')
|
self.assertEquals(sio.getvalue(), '')
|
||||||
sys.stdout = lfo_stdout
|
sys.stdout = lfo_stdout
|
||||||
print 'test2'
|
print('test2')
|
||||||
self.assertEquals(sio.getvalue(), 'STDOUT: test2\n')
|
self.assertEquals(sio.getvalue(), 'STDOUT: test2\n')
|
||||||
sys.stderr = lfo_stderr
|
sys.stderr = lfo_stderr
|
||||||
print >> sys.stderr, 'test4'
|
print('test4', file=sys.stderr)
|
||||||
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n')
|
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n')
|
||||||
sys.stdout = orig_stdout
|
sys.stdout = orig_stdout
|
||||||
print 'test5'
|
print('test5')
|
||||||
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n')
|
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n')
|
||||||
print >> sys.stderr, 'test6'
|
print('test6', file=sys.stderr)
|
||||||
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n'
|
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n'
|
||||||
'STDERR: test6\n')
|
'STDERR: test6\n')
|
||||||
sys.stderr = orig_stderr
|
sys.stderr = orig_stderr
|
||||||
print 'test8'
|
print('test8')
|
||||||
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n'
|
self.assertEquals(sio.getvalue(), 'STDOUT: test2\nSTDERR: test4\n'
|
||||||
'STDERR: test6\n')
|
'STDERR: test6\n')
|
||||||
lfo_stdout.writelines(['a', 'b', 'c'])
|
lfo_stdout.writelines(['a', 'b', 'c'])
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import mock
|
import mock
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ class TestContainerController(TestRingBase):
|
|||||||
self.app._error_limiting = {}
|
self.app._error_limiting = {}
|
||||||
req = Request.blank('/v1/a/c', method=method)
|
req = Request.blank('/v1/a/c', method=method)
|
||||||
with mocked_http_conn(*statuses) as fake_conn:
|
with mocked_http_conn(*statuses) as fake_conn:
|
||||||
print 'a' * 50
|
print('a' * 50)
|
||||||
resp = req.get_response(self.app)
|
resp = req.get_response(self.app)
|
||||||
self.assertEqual(resp.status_int, expected)
|
self.assertEqual(resp.status_int, expected)
|
||||||
for req in fake_conn.requests:
|
for req in fake_conn.requests:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import email.parser
|
import email.parser
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
@ -8460,7 +8461,7 @@ class TestProxyObjectPerformance(unittest.TestCase):
|
|||||||
self.assertEqual(total, self.obj_len)
|
self.assertEqual(total, self.obj_len)
|
||||||
|
|
||||||
end = time.time()
|
end = time.time()
|
||||||
print "Run %02d took %07.03f" % (i, end - start)
|
print("Run %02d took %07.03f" % (i, end - start))
|
||||||
|
|
||||||
|
|
||||||
@patch_policies([StoragePolicy(0, 'migrated', object_ring=FakeRing()),
|
@patch_policies([StoragePolicy(0, 'migrated', object_ring=FakeRing()),
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
@ -74,4 +75,4 @@ if __name__ == "__main__":
|
|||||||
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
|
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
|
||||||
sys.path = sys.argv[1].split(':')
|
sys.path = sys.argv[1].split(':')
|
||||||
from swift import gettext_ as _
|
from swift import gettext_ as _
|
||||||
print _('test message')
|
print(_('test message'))
|
||||||
|
Loading…
Reference in New Issue
Block a user