diff --git a/test/unit/account/test_auditor.py b/test/unit/account/test_auditor.py
index c79209bc09..e4cb382c23 100644
--- a/test/unit/account/test_auditor.py
+++ b/test/unit/account/test_auditor.py
@@ -252,9 +252,9 @@ class TestAuditorRealBroker(unittest.TestCase):
error_lines = test_auditor.logger.get_lines_for_level('error')
self.assertEqual(len(error_lines), 1)
error_message = error_lines[0]
- self.assert_(broker.db_file in error_message)
- self.assert_('container_count' in error_message)
- self.assert_('does not match' in error_message)
+ self.assertTrue(broker.db_file in error_message)
+ self.assertTrue('container_count' in error_message)
+ self.assertTrue('does not match' in error_message)
self.assertEqual(test_auditor.logger.get_increment_counts(),
{'failures': 1})
diff --git a/test/unit/account/test_backend.py b/test/unit/account/test_backend.py
index 6598046487..9dcde99bd3 100644
--- a/test/unit/account/test_backend.py
+++ b/test/unit/account/test_backend.py
@@ -78,35 +78,35 @@ class TestAccountBroker(unittest.TestCase):
raise Exception('OMG')
except Exception:
pass
- self.assert_(broker.conn is None)
+ self.assertTrue(broker.conn is None)
def test_empty(self):
# Test AccountBroker.empty
broker = AccountBroker(':memory:', account='a')
broker.initialize(Timestamp('1').internal)
- self.assert_(broker.empty())
+ self.assertTrue(broker.empty())
broker.put_container('o', Timestamp(time()).internal, 0, 0, 0,
POLICIES.default.idx)
- self.assert_(not broker.empty())
+ self.assertTrue(not broker.empty())
sleep(.00001)
broker.put_container('o', 0, Timestamp(time()).internal, 0, 0,
POLICIES.default.idx)
- self.assert_(broker.empty())
+ self.assertTrue(broker.empty())
def test_is_status_deleted(self):
# Test AccountBroker.is_status_deleted
broker1 = AccountBroker(':memory:', account='a')
broker1.initialize(Timestamp(time()).internal)
- self.assert_(not broker1.is_status_deleted())
+ self.assertTrue(not broker1.is_status_deleted())
broker1.delete_db(Timestamp(time()).internal)
- self.assert_(broker1.is_status_deleted())
+ self.assertTrue(broker1.is_status_deleted())
broker2 = AccountBroker(':memory:', account='a')
broker2.initialize(Timestamp(time()).internal)
# Set delete_timestamp greater than put_timestamp
broker2.merge_timestamps(
time(), Timestamp(time()).internal,
Timestamp(time() + 999).internal)
- self.assert_(broker2.is_status_deleted())
+ self.assertTrue(broker2.is_status_deleted())
def test_reclaim(self):
broker = AccountBroker(':memory:', account='test_account')
@@ -161,22 +161,22 @@ class TestAccountBroker(unittest.TestCase):
broker.put_container('z', 0, 0, 0, 0, POLICIES.default.idx)
broker.reclaim(Timestamp(time()).internal, time())
# self.assertEqual(len(res), 2)
- # self.assert_(isinstance(res, tuple))
+ # self.assertTrue(isinstance(res, tuple))
# containers, account_name = res
- # self.assert_(containers is None)
- # self.assert_(account_name is None)
+ # self.assertTrue(containers is None)
+ # self.assertTrue(account_name is None)
# Now delete the account
broker.delete_db(Timestamp(time()).internal)
broker.reclaim(Timestamp(time()).internal, time())
# self.assertEqual(len(res), 2)
- # self.assert_(isinstance(res, tuple))
+ # self.assertTrue(isinstance(res, tuple))
# containers, account_name = res
# self.assertEqual(account_name, 'test_account')
# self.assertEqual(len(containers), 3)
- # self.assert_('x' in containers)
- # self.assert_('y' in containers)
- # self.assert_('z' in containers)
- # self.assert_('a' not in containers)
+ # self.assertTrue('x' in containers)
+ # self.assertTrue('y' in containers)
+ # self.assertTrue('z' in containers)
+ # self.assertTrue('a' not in containers)
def test_delete_db_status(self):
ts = (Timestamp(t).internal for t in itertools.count(int(time())))
@@ -185,7 +185,7 @@ class TestAccountBroker(unittest.TestCase):
broker.initialize(start)
info = broker.get_info()
self.assertEqual(info['put_timestamp'], Timestamp(start).internal)
- self.assert_(Timestamp(info['created_at']) >= start)
+ self.assertTrue(Timestamp(info['created_at']) >= start)
self.assertEqual(info['delete_timestamp'], '0')
if self.__class__ == TestAccountBrokerBeforeMetadata:
self.assertEqual(info['status_changed_at'], '0')
@@ -198,7 +198,7 @@ class TestAccountBroker(unittest.TestCase):
broker.delete_db(delete_timestamp)
info = broker.get_info()
self.assertEqual(info['put_timestamp'], Timestamp(start).internal)
- self.assert_(Timestamp(info['created_at']) >= start)
+ self.assertTrue(Timestamp(info['created_at']) >= start)
self.assertEqual(info['delete_timestamp'], delete_timestamp)
self.assertEqual(info['status_changed_at'], delete_timestamp)
@@ -830,7 +830,7 @@ class TestAccountBrokerBeforeMetadata(TestAccountBroker):
conn.execute('SELECT metadata FROM account_stat')
except BaseException as err:
exc = err
- self.assert_('no such column: metadata' in str(exc))
+ self.assertTrue('no such column: metadata' in str(exc))
def tearDown(self):
AccountBroker.create_account_stat_table = \
@@ -917,12 +917,12 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
conn.execute('SELECT storage_policy_index FROM container')
except BaseException as err:
exc = err
- self.assert_('no such column: storage_policy_index' in str(exc))
+ self.assertTrue('no such column: storage_policy_index' in str(exc))
with broker.get() as conn:
try:
conn.execute('SELECT * FROM policy_stat')
except sqlite3.OperationalError as err:
- self.assert_('no such table: policy_stat' in str(err))
+ self.assertTrue('no such table: policy_stat' in str(err))
else:
self.fail('database created with policy_stat table')
@@ -949,7 +949,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
''').fetchone()[0]
except sqlite3.OperationalError as err:
# confirm that the table really isn't there
- self.assert_('no such table: policy_stat' in str(err))
+ self.assertTrue('no such table: policy_stat' in str(err))
else:
self.fail('broker did not raise sqlite3.OperationalError '
'trying to select from policy_stat table!')
@@ -985,8 +985,8 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
''').fetchone()[0]
except sqlite3.OperationalError as err:
# confirm that the table doesn't have this column
- self.assert_('no such column: storage_policy_index' in
- str(err))
+ self.assertTrue('no such column: storage_policy_index' in
+ str(err))
else:
self.fail('broker did not raise sqlite3.OperationalError '
'trying to select from storage_policy_index '
@@ -1097,7 +1097,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
self.fail('mock exception was not raised')
self.assertEqual(len(called), 1)
- self.assert_('CREATE TABLE policy_stat' in called[0])
+ self.assertTrue('CREATE TABLE policy_stat' in called[0])
# nothing was committed
broker = AccountBroker(db_path, account='a')
@@ -1105,7 +1105,7 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
try:
conn.execute('SELECT * FROM policy_stat')
except sqlite3.OperationalError as err:
- self.assert_('no such table: policy_stat' in str(err))
+ self.assertTrue('no such table: policy_stat' in str(err))
else:
self.fail('half upgraded database!')
container_count = conn.execute(
@@ -1269,7 +1269,7 @@ class AccountBrokerPreTrackContainerCountSetup(object):
''').fetchone()[0]
except sqlite3.OperationalError as err:
# confirm that the column really isn't there
- self.assert_('no such column: container_count' in str(err))
+ self.assertTrue('no such column: container_count' in str(err))
else:
self.fail('broker did not raise sqlite3.OperationalError '
'trying to select container_count from policy_stat!')
diff --git a/test/unit/account/test_server.py b/test/unit/account/test_server.py
index d3fbb90f41..a52a09bd6e 100644
--- a/test/unit/account/test_server.py
+++ b/test/unit/account/test_server.py
@@ -394,7 +394,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204)
- self.assert_('x-account-meta-test' not in resp.headers)
+ self.assertTrue('x-account-meta-test' not in resp.headers)
def test_PUT_GET_sys_metadata(self):
prefix = get_sys_meta_prefix('account')
@@ -455,7 +455,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204)
- self.assert_(hdr not in resp.headers)
+ self.assertTrue(hdr not in resp.headers)
def test_PUT_invalid_partition(self):
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'PUT',
@@ -519,7 +519,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204)
- self.assert_('x-account-meta-test' not in resp.headers)
+ self.assertTrue('x-account-meta-test' not in resp.headers)
def test_POST_HEAD_sys_metadata(self):
prefix = get_sys_meta_prefix('account')
@@ -572,7 +572,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204)
- self.assert_(hdr not in resp.headers)
+ self.assertTrue(hdr not in resp.headers)
def test_POST_invalid_partition(self):
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'POST',
@@ -1810,7 +1810,7 @@ class TestAccountController(unittest.TestCase):
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int // 100, 2)
for key in resp.headers:
- self.assert_('storage-policy' not in key.lower())
+ self.assertTrue('storage-policy' not in key.lower())
def test_empty_except_for_used_policies(self):
ts = itertools.count()
@@ -1826,7 +1826,7 @@ class TestAccountController(unittest.TestCase):
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int // 100, 2)
for key in resp.headers:
- self.assert_('storage-policy' not in key.lower())
+ self.assertTrue('storage-policy' not in key.lower())
# add a container
policy = random.choice(POLICIES)
@@ -1847,7 +1847,7 @@ class TestAccountController(unittest.TestCase):
self.assertEqual(resp.status_int // 100, 2)
for key in resp.headers:
if 'storage-policy' in key.lower():
- self.assert_(policy.name.lower() in key.lower())
+ self.assertTrue(policy.name.lower() in key.lower())
def test_multiple_policies_in_use(self):
ts = itertools.count()
diff --git a/test/unit/common/middleware/test_acl.py b/test/unit/common/middleware/test_acl.py
index e74044d405..aa100bc4db 100644
--- a/test/unit/common/middleware/test_acl.py
+++ b/test/unit/common/middleware/test_acl.py
@@ -159,48 +159,49 @@ class TestACL(unittest.TestCase):
(args, result, expected))
def test_referrer_allowed(self):
- self.assert_(not acl.referrer_allowed('host', None))
- self.assert_(not acl.referrer_allowed('host', []))
- self.assert_(acl.referrer_allowed(None, ['*']))
- self.assert_(acl.referrer_allowed('', ['*']))
- self.assert_(not acl.referrer_allowed(None, ['specific.host']))
- self.assert_(not acl.referrer_allowed('', ['specific.host']))
- self.assert_(acl.referrer_allowed('http://www.example.com/index.html',
- ['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(not acl.referrer_allowed('host', None))
+ self.assertTrue(not acl.referrer_allowed('host', []))
+ self.assertTrue(acl.referrer_allowed(None, ['*']))
+ self.assertTrue(acl.referrer_allowed('', ['*']))
+ self.assertTrue(not acl.referrer_allowed(None, ['specific.host']))
+ self.assertTrue(not acl.referrer_allowed('', ['specific.host']))
+ self.assertTrue(
+ acl.referrer_allowed('http://www.example.com/index.html',
+ ['.example.com']))
+ self.assertTrue(acl.referrer_allowed(
'http://user@www.example.com/index.html', ['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://user:pass@www.example.com/index.html', ['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://www.example.com:8080/index.html', ['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://user@www.example.com:8080/index.html', ['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://user:pass@www.example.com:8080/index.html',
['.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://user:pass@www.example.com:8080', ['.example.com']))
- self.assert_(acl.referrer_allowed('http://www.example.com',
- ['.example.com']))
- self.assert_(not acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed('http://www.example.com',
+ ['.example.com']))
+ self.assertTrue(not acl.referrer_allowed(
'http://thief.example.com',
['.example.com', '-thief.example.com']))
- self.assert_(not acl.referrer_allowed(
+ self.assertTrue(not acl.referrer_allowed(
'http://thief.example.com',
['*', '-thief.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://www.example.com',
['.other.com', 'www.example.com']))
- self.assert_(acl.referrer_allowed(
+ self.assertTrue(acl.referrer_allowed(
'http://www.example.com',
['-.example.com', 'www.example.com']))
# This is considered a relative uri to the request uri, a mode not
# currently supported.
- self.assert_(not acl.referrer_allowed('www.example.com',
- ['.example.com']))
- self.assert_(not acl.referrer_allowed('../index.html',
- ['.example.com']))
- self.assert_(acl.referrer_allowed('www.example.com', ['*']))
+ self.assertTrue(not acl.referrer_allowed('www.example.com',
+ ['.example.com']))
+ self.assertTrue(not acl.referrer_allowed('../index.html',
+ ['.example.com']))
+ self.assertTrue(acl.referrer_allowed('www.example.com', ['*']))
if __name__ == '__main__':
diff --git a/test/unit/common/middleware/test_bulk.py b/test/unit/common/middleware/test_bulk.py
index d637c2a55b..723a953ae0 100644
--- a/test/unit/common/middleware/test_bulk.py
+++ b/test/unit/common/middleware/test_bulk.py
@@ -297,10 +297,12 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(
req, compress_format, 'application/xml')
- self.assert_('