unit tests: Replace "self.assert_" by "self.assertTrue"

The assert_() method is deprecated and can be safely replaced by assertTrue().
This patch makes sure that running the tests does not create undesired
warnings.

Change-Id: I0602ba39ef93263386644ee68088d5f65fcb4a71
This commit is contained in:
janonymous 2015-07-21 19:23:00 +05:30
parent f3f1f1cab9
commit cd7b2db550
38 changed files with 785 additions and 758 deletions

View File

@ -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})

View File

@ -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!')

View File

@ -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()

View File

@ -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__':

View File

@ -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_('<response_status>201 Created</response_status>' in
resp_body)
self.assert_('<number_files_created>6</number_files_created>' in
resp_body)
self.assertTrue(
'<response_status>201 Created</response_status>' in
resp_body)
self.assertTrue(
'<number_files_created>6</number_files_created>' in
resp_body)
# test out nonexistent format
req = Request.blank('/tar_works/acc/cont/?extract-archive=tar',
@ -316,7 +318,7 @@ class TestUntar(unittest.TestCase):
app_iter = self.bulk(req.environ, fake_start_response)
resp_body = ''.join([i for i in app_iter])
self.assert_('Response Status: 406' in resp_body)
self.assertTrue('Response Status: 406' in resp_body)
def test_extract_call(self):
base_name = 'base_works_gz'
@ -600,10 +602,10 @@ class TestUntar(unittest.TestCase):
def test_get_response_body(self):
txt_body = bulk.get_response_body(
'bad_formay', {'hey': 'there'}, [['json > xml', '202 Accepted']])
self.assert_('hey: there' in txt_body)
self.assertTrue('hey: there' in txt_body)
xml_body = bulk.get_response_body(
'text/xml', {'hey': 'there'}, [['json > xml', '202 Accepted']])
self.assert_('&gt' in xml_body)
self.assertTrue('&gt' in xml_body)
class TestDelete(unittest.TestCase):

View File

@ -69,7 +69,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
@ -79,7 +79,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(FakeApp(True), {})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
@ -96,7 +96,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(
FakeApp(), {'trans_id_suffix': '-stuff'})
req = Request.blank('/v1/a/c/o')
@ -107,7 +107,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(
FakeApp(), {'trans_id_suffix': '-fromconf'})
req = Request.blank('/v1/a/c/o',
@ -119,7 +119,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(
FakeApp(), {'trans_id_suffix': '-fromconf'})
req = Request.blank('/v1/a/c/o',
@ -132,7 +132,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assert_('X-Trans-Id' in (x[0] for x in headers))
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
req = Request.blank('/v1/a/c/o',
headers={'X-Trans-Id-Extra': 'xan than"gum'})

View File

@ -348,7 +348,7 @@ class TestProxyLogging(unittest.TestCase):
[x for x in resp]
log_parts = self._log_parts(app)
headers = unquote(log_parts[14]).split('\n')
self.assert_('Host: localhost:80' in headers)
self.assertTrue('Host: localhost:80' in headers)
def test_access_log_headers_only(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -365,10 +365,10 @@ class TestProxyLogging(unittest.TestCase):
[x for x in resp]
log_parts = self._log_parts(app)
headers = unquote(log_parts[14]).split('\n')
self.assert_('First: 1' in headers)
self.assert_('Second: 2' in headers)
self.assert_('Third: 3' not in headers)
self.assert_('Host: localhost:80' not in headers)
self.assertTrue('First: 1' in headers)
self.assertTrue('Second: 2' in headers)
self.assertTrue('Third: 3' not in headers)
self.assertTrue('Host: localhost:80' not in headers)
def test_upload_size(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(),
@ -488,8 +488,8 @@ class TestProxyLogging(unittest.TestCase):
def test_filter(self):
factory = proxy_logging.filter_factory({})
self.assert_(callable(factory))
self.assert_(callable(factory(FakeApp())))
self.assertTrue(callable(factory))
self.assertTrue(callable(factory(FakeApp())))
def test_unread_body(self):
app = proxy_logging.ProxyLoggingMiddleware(

View File

@ -548,7 +548,7 @@ class TestRateLimit(unittest.TestCase):
def __call__(self, *args, **kwargs):
pass
resp = rate_mid.__call__(env, a_callable())
self.assert_('fake_app' == resp[0])
self.assertTrue('fake_app' == resp[0])
def test_no_memcache(self):
current_rate = 13

View File

@ -116,7 +116,7 @@ class TestSloMiddleware(SloTestCase):
'/v1/a/c/o', headers={'x-static-large-object': "true"},
environ={'REQUEST_METHOD': 'PUT'})
resp = ''.join(self.slo(req.environ, fake_start_response))
self.assert_(
self.assertTrue(
resp.startswith('X-Static-Large-Object is a reserved header'))
def test_parse_input(self):
@ -370,12 +370,13 @@ class TestSloPutManifest(SloTestCase):
status, headers, body = self.call_app(req)
headers = dict(headers)
manifest_data = json.loads(body)
self.assert_(headers['Content-Type'].endswith(';swift_bytes=3'))
self.assertTrue(headers['Content-Type'].endswith(';swift_bytes=3'))
self.assertEquals(len(manifest_data), 2)
self.assertEquals(manifest_data[0]['hash'], 'a')
self.assertEquals(manifest_data[0]['bytes'], 1)
self.assert_(not manifest_data[0]['last_modified'].startswith('2012'))
self.assert_(manifest_data[1]['last_modified'].startswith('2012'))
self.assertTrue(
not manifest_data[0]['last_modified'].startswith('2012'))
self.assertTrue(manifest_data[1]['last_modified'].startswith('2012'))
def test_handle_multipart_put_check_data_bad(self):
bad_data = json.dumps(

View File

@ -487,7 +487,7 @@ class TestStaticWeb(unittest.TestCase):
def test_container3indexhtml(self):
resp = Request.blank('/v1/a/c3/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Test main index.html file.' in resp.body)
self.assertTrue('Test main index.html file.' in resp.body)
def test_container3subsubdir(self):
resp = Request.blank(
@ -504,10 +504,10 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank(
'/v1/a/c3/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c3/subdir/' in resp.body)
self.assert_('</style>' in resp.body)
self.assert_('<link' not in resp.body)
self.assert_('listing.css' not in resp.body)
self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body)
self.assertTrue('</style>' in resp.body)
self.assertTrue('<link' not in resp.body)
self.assertTrue('listing.css' not in resp.body)
def test_container3subdirx(self):
resp = Request.blank(
@ -528,7 +528,7 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank(
'/v1/a/c3/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_("Chrome's 404 fancy-page sucks." not in resp.body)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
def test_container3bindexhtml(self):
resp = Request.blank('/v1/a/c3b/').get_response(self.test_staticweb)
@ -538,8 +538,8 @@ class TestStaticWeb(unittest.TestCase):
def test_container4indexhtml(self):
resp = Request.blank('/v1/a/c4/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c4/' in resp.body)
self.assert_('href="listing.css"' in resp.body)
self.assertTrue('Listing of /v1/a/c4/' in resp.body)
self.assertTrue('href="listing.css"' in resp.body)
def test_container4indexhtmlauthed(self):
resp = Request.blank('/v1/a/c4').get_response(self.test_staticweb)
@ -559,16 +559,16 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank(
'/v1/a/c4/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_("Chrome's 404 fancy-page sucks." in resp.body)
self.assertTrue("Chrome's 404 fancy-page sucks." in resp.body)
def test_container4subdir(self):
resp = Request.blank(
'/v1/a/c4/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c4/subdir/' in resp.body)
self.assert_('</style>' not in resp.body)
self.assert_('<link' in resp.body)
self.assert_('href="../listing.css"' in resp.body)
self.assertTrue('Listing of /v1/a/c4/subdir/' in resp.body)
self.assertTrue('</style>' not in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="../listing.css"' in resp.body)
self.assertEquals(resp.headers['content-type'],
'text/html; charset=UTF-8')
@ -590,7 +590,7 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank(
'/v1/a/c5/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_("Chrome's 404 fancy-page sucks." not in resp.body)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
def test_container6subdir(self):
resp = Request.blank(
@ -600,69 +600,69 @@ class TestStaticWeb(unittest.TestCase):
def test_container7listing(self):
resp = Request.blank('/v1/a/c7/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_('Web Listing Disabled' in resp.body)
self.assertTrue('Web Listing Disabled' in resp.body)
def test_container8listingcss(self):
resp = Request.blank(
'/v1/a/c8/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c8/' in resp.body)
self.assert_('<link' in resp.body)
self.assert_(
self.assertTrue('Listing of /v1/a/c8/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue(
'href="http://localhost/stylesheets/listing.css"' in resp.body)
def test_container8subdirlistingcss(self):
resp = Request.blank(
'/v1/a/c8/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c8/subdir/' in resp.body)
self.assert_('<link' in resp.body)
self.assert_(
self.assertTrue('Listing of /v1/a/c8/subdir/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue(
'href="http://localhost/stylesheets/listing.css"' in resp.body)
def test_container9listingcss(self):
resp = Request.blank(
'/v1/a/c9/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c9/' in resp.body)
self.assert_('<link' in resp.body)
self.assert_('href="/absolute/listing.css"' in resp.body)
self.assertTrue('Listing of /v1/a/c9/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="/absolute/listing.css"' in resp.body)
def test_container9subdirlistingcss(self):
resp = Request.blank(
'/v1/a/c9/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c9/subdir/' in resp.body)
self.assert_('<link' in resp.body)
self.assert_('href="/absolute/listing.css"' in resp.body)
self.assertTrue('Listing of /v1/a/c9/subdir/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="/absolute/listing.css"' in resp.body)
def test_container10unicodesubdirlisting(self):
resp = Request.blank(
'/v1/a/c10/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c10/' in resp.body)
self.assertTrue('Listing of /v1/a/c10/' in resp.body)
resp = Request.blank(
'/v1/a/c10/\xe2\x98\x83/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('Listing of /v1/a/c10/\xe2\x98\x83/' in resp.body)
self.assertTrue('Listing of /v1/a/c10/\xe2\x98\x83/' in resp.body)
resp = Request.blank(
'/v1/a/c10/\xe2\x98\x83/\xe2\x98\x83/'
).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_(
self.assertTrue(
'Listing of /v1/a/c10/\xe2\x98\x83/\xe2\x98\x83/' in resp.body)
def test_container11subdirmarkerobjectindex(self):
resp = Request.blank('/v1/a/c11/subdir/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('<h2>c11 subdir index</h2>' in resp.body)
self.assertTrue('<h2>c11 subdir index</h2>' in resp.body)
def test_container11subdirmarkermatchdirtype(self):
resp = Request.blank('/v1/a/c11a/subdir/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_('Index File Not Found' in resp.body)
self.assertTrue('Index File Not Found' in resp.body)
def test_container11subdirmarkeraltdirtype(self):
resp = Request.blank('/v1/a/c11a/subdir2/').get_response(
@ -678,20 +678,20 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank('/v1/a/c12/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assert_('index file' in resp.body)
self.assertTrue('index file' in resp.body)
def test_container_404_has_css(self):
resp = Request.blank('/v1/a/c13/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_('listing.css' in resp.body)
self.assertTrue('listing.css' in resp.body)
def test_container_404_has_no_css(self):
resp = Request.blank('/v1/a/c7/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assert_('listing.css' not in resp.body)
self.assert_('<style' in resp.body)
self.assertTrue('listing.css' not in resp.body)
self.assertTrue('<style' in resp.body)
def test_subrequest_once_if_possible(self):
resp = Request.blank(

View File

@ -927,7 +927,7 @@ class TestTempURL(unittest.TestCase):
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
def test_clean_incoming_headers(self):
irh = ''

View File

@ -51,9 +51,9 @@ class TestXProfile(unittest.TestCase):
def test_get_profiler(self):
if xprofile is None:
raise SkipTest
self.assert_(xprofile.get_profiler('cProfile') is not None)
self.assert_(xprofile.get_profiler('eventlet.green.profile')
is not None)
self.assertTrue(xprofile.get_profiler('cProfile') is not None)
self.assertTrue(xprofile.get_profiler('eventlet.green.profile')
is not None)
class TestProfilers(unittest.TestCase):
@ -76,8 +76,8 @@ class TestProfilers(unittest.TestCase):
for p in self.profilers:
p.runctx('import os;os.getcwd();', globals(), locals())
p.snapshot_stats()
self.assert_(p.stats is not None)
self.assert_(len(p.stats.keys()) > 0)
self.assertTrue(p.stats is not None)
self.assertTrue(len(p.stats.keys()) > 0)
class TestProfileMiddleware(unittest.TestCase):
@ -136,7 +136,7 @@ class TestProfileMiddleware(unittest.TestCase):
'QUERY_STRING': 'profile=all&format=json',
'wsgi.input': wsgi_input}
resp = self.app(environ, self.start_response)
self.assert_(resp[0].find('<html>') > 0, resp)
self.assertTrue(resp[0].find('<html>') > 0, resp)
self.assertEqual(self.got_statuses, ['200 OK'])
self.assertEqual(self.headers, [('content-type', 'text/html')])
wsgi_input = StringIO.StringIO(body + '&plot=plot')
@ -157,8 +157,8 @@ class TestProfileMiddleware(unittest.TestCase):
wsgi_input = StringIO.StringIO(body + '&download=download&format=json')
environ['wsgi.input'] = wsgi_input
resp = self.app(environ, self.start_response)
self.assert_(self.headers == [('content-type',
HTMLViewer.format_dict['json'])])
self.assertTrue(self.headers == [('content-type',
HTMLViewer.format_dict['json'])])
env2 = environ.copy()
env2['REQUEST_METHOD'] = 'DELETE'
resp = self.app(env2, self.start_response)
@ -181,13 +181,13 @@ class TestProfileMiddleware(unittest.TestCase):
def test_dump_checkpoint(self):
self.app.dump_checkpoint()
self.assert_(self.app.last_dump_at is not None)
self.assertTrue(self.app.last_dump_at is not None)
def test_renew_profile(self):
old_profiler = self.app.profiler
self.app.renew_profile()
new_profiler = self.app.profiler
self.assert_(old_profiler != new_profiler)
self.assertTrue(old_profiler != new_profiler)
class Test_profile_log(unittest.TestCase):
@ -224,7 +224,7 @@ class Test_profile_log(unittest.TestCase):
self.assertEquals(self.profile_log1.get_all_pids(),
sorted(self.pids1, reverse=True))
for pid in self.profile_log2.get_all_pids():
self.assert_(pid.split('-')[0] in self.pids2)
self.assertTrue(pid.split('-')[0] in self.pids2)
def test_clear(self):
self.profile_log1.clear('123')
@ -262,22 +262,22 @@ class Test_profile_log(unittest.TestCase):
self.assertEquals(len(log_files), len(self.pids2))
log_files = self.profile_log2.get_logfiles('current')
self.assertEqual(len(log_files), 1)
self.assert_(log_files[0].find(self.log_filename_prefix2 +
str(os.getpid())) > -1)
self.assertTrue(log_files[0].find(self.log_filename_prefix2 +
str(os.getpid())) > -1)
log_files = self.profile_log2.get_logfiles(self.pids2[0])
self.assertEqual(len(log_files), 1)
self.assert_(log_files[0].find(self.log_filename_prefix2 +
self.pids2[0]) > -1)
self.assertTrue(log_files[0].find(self.log_filename_prefix2 +
self.pids2[0]) > -1)
def test_dump_profile(self):
prof = xprofile.get_profiler('eventlet.green.profile')
prof.runctx('import os;os.getcwd();', globals(), locals())
prof.create_stats()
pfn = self.profile_log1.dump_profile(prof, os.getpid())
self.assert_(os.path.exists(pfn))
self.assertTrue(os.path.exists(pfn))
os.remove(pfn)
pfn = self.profile_log2.dump_profile(prof, os.getpid())
self.assert_(os.path.exists(pfn))
self.assertTrue(os.path.exists(pfn))
os.remove(pfn)
@ -345,12 +345,12 @@ class Test_html_viewer(unittest.TestCase):
content, headers = self.viewer.render(url, 'GET', path_entries[0],
self.query_dict, None)
self.assert_(content is not None)
self.assertTrue(content is not None)
self.assertEqual(headers, [('content-type', 'text/html')])
content, headers = self.viewer.render(url, 'POST', path_entries[0],
self.query_dict, None)
self.assert_(content is not None)
self.assertTrue(content is not None)
self.assertEqual(headers, [('content-type', 'text/html')])
plot_dict = self.query_dict.copy()
@ -375,12 +375,12 @@ class Test_html_viewer(unittest.TestCase):
download_dict['download'] = ['download']
content, headers = self.viewer.render(url, 'POST', path_entries[0],
download_dict, None)
self.assert_(headers == [('content-type',
self.viewer.format_dict['default'])])
self.assertTrue(headers == [('content-type',
self.viewer.format_dict['default'])])
content, headers = self.viewer.render(url, 'GET', path_entries[1],
self.query_dict, None)
self.assert_(isinstance(json.loads(content), dict))
self.assertTrue(isinstance(json.loads(content), dict))
for method in ['HEAD', 'PUT', 'DELETE', 'XYZMethod']:
self.assertRaises(MethodNotAllowed, self.viewer.render, url,
@ -390,34 +390,35 @@ class Test_html_viewer(unittest.TestCase):
download_dict['format'] = 'default'
content, headers = self.viewer.render(url, 'GET', entry,
download_dict, None)
self.assert_(('content-type', self.viewer.format_dict['default'])
in headers, entry)
self.assertTrue(
('content-type', self.viewer.format_dict['default'])
in headers, entry)
download_dict['format'] = 'json'
content, headers = self.viewer.render(url, 'GET', entry,
download_dict, None)
self.assert_(isinstance(json.loads(content), dict))
self.assertTrue(isinstance(json.loads(content), dict))
def test_index(self):
content, headers = self.viewer.index_page(self.log_files[0:1],
profile_id='current')
self.assert_(content.find('<html>') > -1)
self.assert_(headers == [('content-type', 'text/html')])
self.assertTrue(content.find('<html>') > -1)
self.assertTrue(headers == [('content-type', 'text/html')])
def test_index_all(self):
content, headers = self.viewer.index_page(self.log_files,
profile_id='all')
for f in self.log_files:
self.assert_(content.find(f) > 0, content)
self.assert_(headers == [('content-type', 'text/html')])
self.assertTrue(content.find(f) > 0, content)
self.assertTrue(headers == [('content-type', 'text/html')])
def test_download(self):
content, headers = self.viewer.download(self.log_files)
self.assert_(content is not None)
self.assertTrue(content is not None)
self.assertEqual(headers, [('content-type',
self.viewer.format_dict['default'])])
content, headers = self.viewer.download(self.log_files, sort='calls',
limit=10, nfl_filter='os')
self.assert_(content is not None)
self.assertTrue(content is not None)
self.assertEqual(headers, [('content-type',
self.viewer.format_dict['default'])])
content, headers = self.viewer.download(self.log_files,
@ -426,7 +427,7 @@ class Test_html_viewer(unittest.TestCase):
self.viewer.format_dict['default'])])
content, headers = self.viewer.download(self.log_files,
output_format='json')
self.assert_(isinstance(json.loads(content), dict))
self.assertTrue(isinstance(json.loads(content), dict))
self.assertEqual(headers, [('content-type',
self.viewer.format_dict['json'])])
content, headers = self.viewer.download(self.log_files,
@ -450,7 +451,7 @@ class Test_html_viewer(unittest.TestCase):
def test_plot(self):
if PLOTLIB_INSTALLED:
content, headers = self.viewer.plot(self.log_files)
self.assert_(content is not None)
self.assertTrue(content is not None)
self.assertEqual(headers, [('content-type', 'image/jpg')])
self.assertRaises(NotFoundException, self.viewer.plot, [])
else:
@ -459,16 +460,16 @@ class Test_html_viewer(unittest.TestCase):
def test_format_source_code(self):
nfl_os = '%s:%d(%s)' % (os.__file__[:-1], 136, 'makedirs')
self.assert_('makedirs' in self.viewer.format_source_code(nfl_os))
self.assertTrue('makedirs' in self.viewer.format_source_code(nfl_os))
self.assertFalse('makedirsXYZ' in
self.viewer.format_source_code(nfl_os))
nfl_illegal = '%s:136(makedirs)' % os.__file__
self.assert_(_('The file type are forbidden to access!') in
self.viewer.format_source_code(nfl_illegal))
self.assertTrue(_('The file type are forbidden to access!') in
self.viewer.format_source_code(nfl_illegal))
nfl_not_exist = '%s.py:136(makedirs)' % os.__file__
expected_msg = _('Can not access the file %s.') % os.__file__
self.assert_(expected_msg in
self.viewer.format_source_code(nfl_not_exist))
self.assertTrue(expected_msg in
self.viewer.format_source_code(nfl_not_exist))
class TestStats2(unittest.TestCase):
@ -500,19 +501,19 @@ class TestStats2(unittest.TestCase):
def test_to_json(self):
for selection in self.selections:
js = self.stats2.to_json(selection)
self.assert_(isinstance(json.loads(js), dict))
self.assert_(json.loads(js)['stats'] is not None)
self.assert_(json.loads(js)['stats'][0] is not None)
self.assertTrue(isinstance(json.loads(js), dict))
self.assertTrue(json.loads(js)['stats'] is not None)
self.assertTrue(json.loads(js)['stats'][0] is not None)
def test_to_ods(self):
if ODFLIB_INSTALLED:
for selection in self.selections:
self.assert_(self.stats2.to_ods(selection) is not None)
self.assertTrue(self.stats2.to_ods(selection) is not None)
def test_to_csv(self):
for selection in self.selections:
self.assert_(self.stats2.to_csv(selection) is not None)
self.assert_('function calls' in self.stats2.to_csv(selection))
self.assertTrue(self.stats2.to_csv(selection) is not None)
self.assertTrue('function calls' in self.stats2.to_csv(selection))
if __name__ == '__main__':

View File

@ -120,14 +120,14 @@ class TestRingBuilder(unittest.TestCase):
rb.remove_dev(1)
rb.rebalance()
r = rb.get_ring()
self.assert_(isinstance(r, ring.RingData))
self.assertTrue(isinstance(r, ring.RingData))
r2 = rb.get_ring()
self.assert_(r is r2)
self.assertTrue(r is r2)
rb.rebalance()
r3 = rb.get_ring()
self.assert_(r3 is not r2)
self.assertTrue(r3 is not r2)
r4 = rb.get_ring()
self.assert_(r3 is r4)
self.assertTrue(r3 is r4)
def test_rebalance_with_seed(self):
devs = [(0, 10000), (1, 10001), (2, 10002), (1, 10003)]
@ -358,7 +358,7 @@ class TestRingBuilder(unittest.TestCase):
_, balance = rb.rebalance(seed=2)
# maybe not *perfect*, but should be close
self.assert_(balance <= 1)
self.assertTrue(balance <= 1)
def test_multitier_partial(self):
# Multitier test, nothing full
@ -1520,8 +1520,8 @@ class TestRingBuilder(unittest.TestCase):
self.assertEquals(counts, {0: 128, 1: 128, 2: 256, 3: 256})
dev_usage, worst = rb.validate()
self.assert_(dev_usage is None)
self.assert_(worst is None)
self.assertTrue(dev_usage is None)
self.assertTrue(worst is None)
dev_usage, worst = rb.validate(stats=True)
self.assertEquals(list(dev_usage), [128, 128, 256, 256])

View File

@ -49,7 +49,7 @@ class TestConstraints(unittest.TestCase):
def test_check_metadata_empty_name(self):
headers = {'X-Object-Meta-': 'Value'}
self.assert_(constraints.check_metadata(Request.blank(
self.assertTrue(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), HTTPBadRequest)
def test_check_metadata_name_length(self):
@ -215,7 +215,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assert_('Content-Type' in resp.body)
self.assertTrue('Content-Type' in resp.body)
def test_check_object_creation_bad_delete_headers(self):
headers = {'Transfer-Encoding': 'chunked',
@ -224,7 +224,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assert_('Non-integer X-Delete-After' in resp.body)
self.assertTrue('Non-integer X-Delete-After' in resp.body)
t = str(int(time.time() - 60))
headers = {'Transfer-Encoding': 'chunked',
@ -233,7 +233,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assert_('X-Delete-At in past' in resp.body)
self.assertTrue('X-Delete-At in past' in resp.body)
def test_check_delete_headers(self):

View File

@ -52,7 +52,7 @@ class TestDaemon(unittest.TestCase):
def test_create(self):
d = daemon.Daemon({})
self.assertEquals(d.conf, {})
self.assert_(isinstance(d.logger, utils.LogAdapter))
self.assertTrue(isinstance(d.logger, utils.LogAdapter))
def test_stubs(self):
d = daemon.Daemon({})
@ -88,7 +88,7 @@ class TestRunDaemon(unittest.TestCase):
with patch.dict('os.environ', {'TZ': ''}):
daemon.run_daemon(MyDaemon, conf_file)
self.assertEquals(MyDaemon.forever_called, True)
self.assert_(os.environ['TZ'] is not '')
self.assertTrue(os.environ['TZ'] is not '')
daemon.run_daemon(MyDaemon, conf_file, once=True)
self.assertEquals(MyDaemon.once_called, True)
@ -104,7 +104,7 @@ class TestRunDaemon(unittest.TestCase):
logger.addHandler(logging.StreamHandler(sio))
logger = utils.get_logger(None, 'server', log_route='server')
daemon.run_daemon(MyDaemon, conf_file, logger=logger)
self.assert_('user quit' in sio.getvalue().lower())
self.assertTrue('user quit' in sio.getvalue().lower())
if __name__ == '__main__':

View File

@ -51,14 +51,14 @@ class TestDatabaseConnectionError(unittest.TestCase):
def test_str(self):
err = \
DatabaseConnectionError(':memory:', 'No valid database connection')
self.assert_(':memory:' in str(err))
self.assert_('No valid database connection' in str(err))
self.assertTrue(':memory:' in str(err))
self.assertTrue('No valid database connection' in str(err))
err = DatabaseConnectionError(':memory:',
'No valid database connection',
timeout=1357)
self.assert_(':memory:' in str(err))
self.assert_('No valid database connection' in str(err))
self.assert_('1357' in str(err))
self.assertTrue(':memory:' in str(err))
self.assertTrue('No valid database connection' in str(err))
self.assertTrue('1357' in str(err))
class TestDictFactory(unittest.TestCase):
@ -157,7 +157,7 @@ class TestGetDBConnection(unittest.TestCase):
def test_normal_case(self):
conn = get_db_connection(':memory:')
self.assert_(hasattr(conn, 'execute'))
self.assertTrue(hasattr(conn, 'execute'))
def test_invalid_path(self):
self.assertRaises(DatabaseConnectionError, get_db_connection,
@ -323,12 +323,12 @@ class TestExampleBroker(unittest.TestCase):
# delete
delete_timestamp = next(self.ts)
broker.merge_timestamps(created_at, put_timestamp, delete_timestamp)
self.assert_(broker.is_deleted())
self.assertTrue(broker.is_deleted())
info = broker.get_info()
self.assertEqual(info['created_at'], created_at)
self.assertEqual(info['put_timestamp'], put_timestamp)
self.assertEqual(info['delete_timestamp'], delete_timestamp)
self.assert_(info['status_changed_at'] > Timestamp(put_timestamp))
self.assertTrue(info['status_changed_at'] > Timestamp(put_timestamp))
def put_item(self, broker, timestamp):
broker.put_test('test', timestamp)
@ -365,7 +365,7 @@ class TestExampleBroker(unittest.TestCase):
self.delete_item(broker, next(self.ts))
self.assertEqual(broker.get_info()[
'%s_count' % broker.db_contains_type], 0)
self.assert_(broker.is_deleted())
self.assertTrue(broker.is_deleted())
def test_merge_timestamps_simple_recreate(self):
put_timestamp = next(self.ts)
@ -375,14 +375,14 @@ class TestExampleBroker(unittest.TestCase):
created_at = broker.get_info()['created_at']
delete_timestamp = next(self.ts)
broker.merge_timestamps(created_at, put_timestamp, delete_timestamp)
self.assert_(broker.is_deleted())
self.assertTrue(broker.is_deleted())
info = broker.get_info()
self.assertEqual(info['created_at'], created_at)
self.assertEqual(info['put_timestamp'], put_timestamp)
self.assertEqual(info['delete_timestamp'], delete_timestamp)
orig_status_changed_at = info['status_changed_at']
self.assert_(orig_status_changed_at >
Timestamp(virgin_status_changed_at))
self.assertTrue(orig_status_changed_at >
Timestamp(virgin_status_changed_at))
# recreate
recreate_timestamp = next(self.ts)
status_changed_at = time.time()
@ -393,7 +393,7 @@ class TestExampleBroker(unittest.TestCase):
self.assertEqual(info['created_at'], created_at)
self.assertEqual(info['put_timestamp'], recreate_timestamp)
self.assertEqual(info['delete_timestamp'], delete_timestamp)
self.assert_(info['status_changed_at'], status_changed_at)
self.assertTrue(info['status_changed_at'], status_changed_at)
def test_merge_timestamps_recreate_with_objects(self):
put_timestamp = next(self.ts)
@ -403,14 +403,14 @@ class TestExampleBroker(unittest.TestCase):
# delete
delete_timestamp = next(self.ts)
broker.merge_timestamps(created_at, put_timestamp, delete_timestamp)
self.assert_(broker.is_deleted())
self.assertTrue(broker.is_deleted())
info = broker.get_info()
self.assertEqual(info['created_at'], created_at)
self.assertEqual(info['put_timestamp'], put_timestamp)
self.assertEqual(info['delete_timestamp'], delete_timestamp)
orig_status_changed_at = info['status_changed_at']
self.assert_(Timestamp(orig_status_changed_at) >=
Timestamp(put_timestamp))
self.assertTrue(Timestamp(orig_status_changed_at) >=
Timestamp(put_timestamp))
# add object
self.put_item(broker, next(self.ts))
count_key = '%s_count' % broker.db_contains_type
@ -607,7 +607,7 @@ class TestDatabaseBroker(unittest.TestCase):
db_file = os.path.join(self.testdir, '1.db')
broker = DatabaseBroker(db_file)
self.assertEqual(broker.db_file, db_file)
self.assert_(broker.conn is None)
self.assertTrue(broker.conn is None)
def test_disk_preallocate(self):
test_size = [-1]
@ -641,7 +641,7 @@ class TestDatabaseBroker(unittest.TestCase):
broker = DatabaseBroker(':memory:')
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
self.assert_(hasattr(stub_dict['args'][0], 'execute'))
self.assertTrue(hasattr(stub_dict['args'][0], 'execute'))
self.assertEquals(stub_dict['args'][1], '0000000001.00000')
with broker.get() as conn:
conn.execute('SELECT * FROM outgoing_sync')
@ -649,7 +649,7 @@ class TestDatabaseBroker(unittest.TestCase):
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
self.assert_(hasattr(stub_dict['args'][0], 'execute'))
self.assertTrue(hasattr(stub_dict['args'][0], 'execute'))
self.assertEquals(stub_dict['args'][1], '0000000001.00000')
with broker.get() as conn:
conn.execute('SELECT * FROM outgoing_sync')
@ -676,11 +676,11 @@ class TestDatabaseBroker(unittest.TestCase):
broker._initialize = init_stub
# Initializes a good broker for us
broker.initialize(normalize_timestamp('1'))
self.assert_(broker.conn is not None)
self.assertTrue(broker.conn is not None)
broker._delete_db = delete_stub
stub_called[0] = False
broker.delete_db('2')
self.assert_(stub_called[0])
self.assertTrue(stub_called[0])
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
broker.db_type = 'test'
broker._initialize = init_stub
@ -688,12 +688,12 @@ class TestDatabaseBroker(unittest.TestCase):
broker._delete_db = delete_stub
stub_called[0] = False
broker.delete_db('2')
self.assert_(stub_called[0])
self.assertTrue(stub_called[0])
# ensure that metadata was cleared
m2 = broker.metadata
self.assert_(not any(v[0] for v in m2.itervalues()))
self.assert_(all(v[1] == normalize_timestamp('2')
for v in m2.itervalues()))
self.assertTrue(not any(v[0] for v in m2.itervalues()))
self.assertTrue(all(v[1] == normalize_timestamp('2')
for v in m2.itervalues()))
def test_get(self):
broker = DatabaseBroker(':memory:')
@ -710,7 +710,7 @@ class TestDatabaseBroker(unittest.TestCase):
conn.execute('SELECT 1')
except Exception:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
def stub(*args, **kwargs):
pass
@ -783,7 +783,7 @@ class TestDatabaseBroker(unittest.TestCase):
pass
except Exception:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
def stub(*args, **kwargs):
pass
@ -803,7 +803,7 @@ class TestDatabaseBroker(unittest.TestCase):
pass
except LockTimeout:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
try:
with broker.lock():
raise Exception('test')
@ -1061,61 +1061,61 @@ class TestDatabaseBroker(unittest.TestCase):
first_timestamp = normalize_timestamp(1)
first_value = '1'
broker.update_metadata({'First': [first_value, first_timestamp]})
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
# Add our second item
second_timestamp = normalize_timestamp(2)
second_value = '2'
broker.update_metadata({'Second': [second_value, second_timestamp]})
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' in broker.metadata)
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
[second_value, second_timestamp])
# Update our first item
first_timestamp = normalize_timestamp(3)
first_value = '1b'
broker.update_metadata({'First': [first_value, first_timestamp]})
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' in broker.metadata)
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
[second_value, second_timestamp])
# Delete our second item (by setting to empty string)
second_timestamp = normalize_timestamp(4)
second_value = ''
broker.update_metadata({'Second': [second_value, second_timestamp]})
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' in broker.metadata)
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim at point before second item was deleted
reclaim(broker, normalize_timestamp(3))
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' in broker.metadata)
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim at point second item was deleted
reclaim(broker, normalize_timestamp(4))
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' in broker.metadata)
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim after point second item was deleted
reclaim(broker, normalize_timestamp(5))
self.assert_('First' in broker.metadata)
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
[first_value, first_timestamp])
self.assert_('Second' not in broker.metadata)
self.assertTrue('Second' not in broker.metadata)
@patch.object(DatabaseBroker, 'validate_metadata')
def test_validate_metadata_is_called_from_update_metadata(self, mock):

View File

@ -385,7 +385,7 @@ class TestDBReplicator(unittest.TestCase):
remote_file = 'rsync_ip(127.0.0.1)::container/sda1/tmp/abcd'
replicator = MyTestReplicator(broker.db_file, remote_file)
replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd')
self.assert_(replicator._rsync_file_called)
self.assertTrue(replicator._rsync_file_called)
with patch('swift.common.db_replicator.rsync_ip', mock_rsync_ip):
broker = FakeBroker()
@ -393,7 +393,7 @@ class TestDBReplicator(unittest.TestCase):
replicator = MyTestReplicator(broker.db_file, remote_file)
replicator.vm_test_mode = True
replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd')
self.assert_(replicator._rsync_file_called)
self.assertTrue(replicator._rsync_file_called)
def test_rsync_db_rsync_file_failure(self):
class MyTestReplicator(TestReplicator):
@ -588,7 +588,7 @@ class TestDBReplicator(unittest.TestCase):
raise OSError(errno.EEXIST, "File already exists")
self.assertEquals('/a/b/c/d/e', was)
if '-' in new:
self.assert_(
self.assertTrue(
new.startswith('/a/quarantined/containers/e-'))
else:
self.assertEquals('/a/quarantined/containers/e', new)

View File

@ -117,7 +117,7 @@ class TestDirectClient(unittest.TestCase):
now = time.time()
headers = direct_client.gen_headers(add_ts=True)
self.assertEqual(headers['user-agent'], stub_user_agent)
self.assert_(now - 1 < Timestamp(headers['x-timestamp']) < now + 1)
self.assertTrue(now - 1 < Timestamp(headers['x-timestamp']) < now + 1)
self.assertEqual(headers['x-timestamp'],
Timestamp(headers['x-timestamp']).internal)
self.assertEqual(2, len(headers))
@ -146,7 +146,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(
headers['x-timestamp'],
Timestamp(headers['x-timestamp']).internal)
self.assert_(
self.assertTrue(
now - 1 < Timestamp(headers['x-timestamp']) < now + 1)
self.assertEqual(expected_header_count, len(headers))
@ -194,7 +194,8 @@ class TestDirectClient(unittest.TestCase):
'status 500',
)
for item in expected_err_msg_parts:
self.assert_(item in str(err), '%r was not in "%s"' % (item, err))
self.assertTrue(
item in str(err), '%r was not in "%s"' % (item, err))
self.assertEqual(err.http_host, self.node['ip'])
self.assertEqual(err.http_port, self.node['port'])
self.assertEqual(err.http_device, self.node['device'])
@ -231,7 +232,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.method, 'GET')
self.assertEqual(conn.path, self.account_path)
self.assertEqual(err.http_status, 500)
self.assert_('GET' in str(err))
self.assertTrue('GET' in str(err))
def test_direct_delete_account(self):
node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda'}
@ -248,7 +249,7 @@ class TestDirectClient(unittest.TestCase):
path = args[3]
self.assertEqual('/sda/0/a', path)
headers = args[4]
self.assert_('X-Timestamp' in headers)
self.assertTrue('X-Timestamp' in headers)
def test_direct_head_container(self):
headers = HeaderKeyDict(key='value')
@ -281,7 +282,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assertEqual(err.http_status, 503)
self.assertEqual(err.http_headers, headers)
self.assert_('HEAD' in str(err))
self.assertTrue('HEAD' in str(err))
def test_direct_head_container_deleted(self):
important_timestamp = Timestamp(time.time()).internal
@ -293,7 +294,7 @@ class TestDirectClient(unittest.TestCase):
direct_client.direct_head_container(
self.node, self.part, self.account, self.container)
except Exception as err:
self.assert_(isinstance(err, ClientException))
self.assertTrue(isinstance(err, ClientException))
else:
self.fail('ClientException not raised')
self.assertEqual(conn.method, 'HEAD')
@ -369,7 +370,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.path, self.container_path)
self.assertEqual(err.http_status, 500)
self.assert_('DELETE' in str(err))
self.assertTrue('DELETE' in str(err))
def test_direct_put_container_object(self):
headers = {'x-foo': 'bar'}
@ -380,7 +381,7 @@ class TestDirectClient(unittest.TestCase):
headers=headers)
self.assertEqual(conn.method, 'PUT')
self.assertEqual(conn.path, self.obj_path)
self.assert_('x-timestamp' in conn.req_headers)
self.assertTrue('x-timestamp' in conn.req_headers)
self.assertEqual('bar', conn.req_headers.get('x-foo'))
self.assertEqual(rv, None)
@ -400,7 +401,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.path, self.obj_path)
self.assertEqual(err.http_status, 500)
self.assert_('PUT' in str(err))
self.assertTrue('PUT' in str(err))
def test_direct_delete_container_object(self):
with mocked_http_conn(204) as conn:
@ -426,7 +427,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.path, self.obj_path)
self.assertEqual(err.http_status, 500)
self.assert_('DELETE' in str(err))
self.assertTrue('DELETE' in str(err))
def test_direct_head_object(self):
headers = HeaderKeyDict({'x-foo': 'bar'})
@ -440,8 +441,8 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assertEqual('bar', conn.req_headers.get('x-foo'))
self.assert_('x-timestamp' not in conn.req_headers,
'x-timestamp was in HEAD request headers')
self.assertTrue('x-timestamp' not in conn.req_headers,
'x-timestamp was in HEAD request headers')
self.assertEqual(headers, resp)
def test_direct_head_object_error(self):
@ -458,7 +459,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.path, self.obj_path)
self.assertEqual(err.http_status, 500)
self.assert_('HEAD' in str(err))
self.assertTrue('HEAD' in str(err))
def test_direct_head_object_not_found(self):
important_timestamp = Timestamp(time.time()).internal
@ -503,7 +504,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.path, self.obj_path)
self.assertEqual(err.http_status, 500)
self.assert_('GET' in str(err))
self.assertTrue('GET' in str(err))
def test_direct_post_object(self):
headers = {'Key': 'value'}
@ -537,10 +538,10 @@ class TestDirectClient(unittest.TestCase):
for header in headers:
self.assertEqual(conn.req_headers[header], headers[header])
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assert_('x-timestamp' in conn.req_headers)
self.assertTrue('x-timestamp' in conn.req_headers)
self.assertEqual(err.http_status, 500)
self.assert_('POST' in str(err))
self.assertTrue('POST' in str(err))
def test_direct_delete_object(self):
with mocked_http_conn(200) as conn:
@ -576,7 +577,7 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.method, 'DELETE')
self.assertEqual(conn.path, self.obj_path)
self.assertEqual(err.http_status, 503)
self.assert_('DELETE' in str(err))
self.assertTrue('DELETE' in str(err))
def test_direct_put_object_with_content_length(self):
contents = StringIO.StringIO('123456')

View File

@ -140,8 +140,8 @@ class TestManagerModule(unittest.TestCase):
self.assertEquals(myfunc(0), 0)
self.assertEquals(myfunc(True), 1)
self.assertEquals(myfunc(False), 0)
self.assert_(hasattr(myfunc, 'publicly_accessible'))
self.assert_(myfunc.publicly_accessible)
self.assertTrue(hasattr(myfunc, 'publicly_accessible'))
self.assertTrue(myfunc.publicly_accessible)
def test_watch_server_pids(self):
class MockOs(object):
@ -275,7 +275,7 @@ class TestManagerModule(unittest.TestCase):
manager.safe_kill(4, signal.SIGHUP, 'same-procname')
def test_exc(self):
self.assert_(issubclass(manager.UnknownCommandError, Exception))
self.assertTrue(issubclass(manager.UnknownCommandError, Exception))
class TestServer(unittest.TestCase):
@ -307,8 +307,8 @@ class TestServer(unittest.TestCase):
def test_server_repr(self):
server = manager.Server('proxy')
self.assert_(server.__class__.__name__ in repr(server))
self.assert_(str(server) in repr(server))
self.assertTrue(server.__class__.__name__ in repr(server))
self.assertTrue(str(server) in repr(server))
def test_server_equality(self):
server1 = manager.Server('Proxy')
@ -407,7 +407,7 @@ class TestServer(unittest.TestCase):
c3 = self.join_swift_dir('object-server/object3.conf')
c4 = self.join_swift_dir('object-server/conf/server4.conf')
for c in [c1, c2, c3, c4]:
self.assert_(c in conf_files)
self.assertTrue(c in conf_files)
# test configs returned sorted
sorted_confs = sorted([c1, c2, c3, c4])
self.assertEquals(conf_files, sorted_confs)
@ -462,8 +462,8 @@ class TestServer(unittest.TestCase):
# check warn "unable to locate"
conf_files = server.conf_files()
self.assertFalse(conf_files)
self.assert_('unable to locate config for auth'
in pop_stream(f).lower())
self.assertTrue('unable to locate config for auth'
in pop_stream(f).lower())
# check quiet will silence warning
conf_files = server.conf_files(verbose=True, quiet=True)
self.assertEquals(pop_stream(f), '')
@ -473,13 +473,13 @@ class TestServer(unittest.TestCase):
self.assertEquals(pop_stream(f), '')
# check missing config number warn "unable to locate"
conf_files = server.conf_files(number=2)
self.assert_(
self.assertTrue(
'unable to locate config number 2 for ' +
'container-auditor' in pop_stream(f).lower())
# check verbose lists configs
conf_files = server.conf_files(number=2, verbose=True)
c1 = self.join_swift_dir('container-server/1.conf')
self.assert_(c1 in pop_stream(f))
self.assertTrue(c1 in pop_stream(f))
finally:
sys.stdout = old_stdout
@ -533,7 +533,7 @@ class TestServer(unittest.TestCase):
for named_conf in ('server', 'replication'):
conf_dir = self.join_swift_dir(
'object-server/object-%s.conf.d' % named_conf)
self.assert_(conf_dir in conf_dirs)
self.assertTrue(conf_dir in conf_dirs)
def test_conf_dir(self):
conf_files = (
@ -557,7 +557,7 @@ class TestServer(unittest.TestCase):
c3 = self.join_swift_dir('object-server/3.conf.d')
c4 = self.join_swift_dir('object-server/4.conf.d')
for c in [c1, c2, c3, c4]:
self.assert_(c in conf_dirs)
self.assertTrue(c in conf_dirs)
# test configs returned sorted
sorted_confs = sorted([c1, c2, c3, c4])
self.assertEquals(conf_dirs, sorted_confs)
@ -583,7 +583,7 @@ class TestServer(unittest.TestCase):
for named_pid in ('server', 'replication'):
pid_file = self.join_run_dir(
'object-server/object-%s.pid.d' % named_pid)
self.assert_(pid_file in pid_files)
self.assertTrue(pid_file in pid_files)
def test_iter_pid_files(self):
"""
@ -715,7 +715,7 @@ class TestServer(unittest.TestCase):
server = manager.Server('proxy', run_dir=manager.RUN_DIR)
pids = server.signal_pids(DUMMY_SIG)
self.assertEquals(len(pids), 1)
self.assert_(1 in pids)
self.assertTrue(1 in pids)
self.assertEquals(manager.os.pid_sigs[1], [DUMMY_SIG])
# make sure other process not signaled
self.assertFalse(2 in pids)
@ -728,8 +728,8 @@ class TestServer(unittest.TestCase):
# test print details
pids = server.signal_pids(DUMMY_SIG)
output = pop_stream(f)
self.assert_('pid: %s' % 1 in output)
self.assert_('signal: %s' % DUMMY_SIG in output)
self.assertTrue('pid: %s' % 1 in output)
self.assertTrue('signal: %s' % DUMMY_SIG in output)
# test no details on signal.SIG_DFL
pids = server.signal_pids(signal.SIG_DFL)
self.assertEquals(pop_stream(f), '')
@ -737,8 +737,8 @@ class TestServer(unittest.TestCase):
manager.os = MockOs([2])
# test pid not running
pids = server.signal_pids(signal.SIG_DFL)
self.assert_(1 not in pids)
self.assert_(1 not in manager.os.pid_sigs)
self.assertTrue(1 not in pids)
self.assertTrue(1 not in manager.os.pid_sigs)
# test remove stale pid file
self.assertFalse(os.path.exists(
self.join_run_dir('proxy-server.pid')))
@ -748,9 +748,9 @@ class TestServer(unittest.TestCase):
# test verbose warns on removing stale pid file
pids = server.signal_pids(signal.SIG_DFL, verbose=True)
output = pop_stream(f)
self.assert_('stale pid' in output.lower())
self.assertTrue('stale pid' in output.lower())
auth_pid = self.join_run_dir('auth-server.pid')
self.assert_(auth_pid in output)
self.assertTrue(auth_pid in output)
# reset mock os so only the third server is running
manager.os = MockOs([3])
server = manager.Server('one', run_dir=manager.RUN_DIR)
@ -758,9 +758,9 @@ class TestServer(unittest.TestCase):
pids = server.signal_pids(signal.SIG_DFL, verbose=True)
output = pop_stream(f)
old_stdout.write('output %s' % output)
self.assert_('removing pid file' in output.lower())
self.assertTrue('removing pid file' in output.lower())
one_pid = self.join_run_dir('one-server.pid')
self.assert_(one_pid in output)
self.assertTrue(one_pid in output)
server = manager.Server('zero', run_dir=manager.RUN_DIR)
self.assertTrue(os.path.exists(
@ -769,7 +769,7 @@ class TestServer(unittest.TestCase):
pids = server.signal_pids(signal.SIG_DFL, verbose=True)
output = pop_stream(f)
old_stdout.write('output %s' % output)
self.assert_('with invalid pid' in output.lower())
self.assertTrue('with invalid pid' in output.lower())
self.assertFalse(os.path.exists(
self.join_run_dir('zero-server.pid')))
server = manager.Server('invalid-server',
@ -780,7 +780,7 @@ class TestServer(unittest.TestCase):
pids = server.signal_pids(signal.SIG_DFL, verbose=True)
output = pop_stream(f)
old_stdout.write('output %s' % output)
self.assert_('with invalid pid' in output.lower())
self.assertTrue('with invalid pid' in output.lower())
self.assertFalse(os.path.exists(
self.join_run_dir('invalid-server.pid')))
@ -790,8 +790,8 @@ class TestServer(unittest.TestCase):
server = manager.Server('object', run_dir=manager.RUN_DIR)
pids = server.signal_pids(manager.os.RAISE_EPERM_SIG)
output = pop_stream(f)
self.assert_('no permission to signal pid 4' in
output.lower(), output)
self.assertTrue('no permission to signal pid 4' in
output.lower(), output)
finally:
sys.stdout = old_stdout
@ -813,11 +813,11 @@ class TestServer(unittest.TestCase):
manager.os = MockOs([1, 3])
running_pids = server.get_running_pids()
self.assertEquals(len(running_pids), 1)
self.assert_(1 in running_pids)
self.assert_(2 not in running_pids)
self.assert_(3 not in running_pids)
self.assertTrue(1 in running_pids)
self.assertTrue(2 not in running_pids)
self.assertTrue(3 not in running_pids)
# test persistent running pid files
self.assert_(os.path.exists(
self.assertTrue(os.path.exists(
os.path.join(manager.RUN_DIR, 'test-server1.pid')))
# test clean up stale pids
pid_two = self.join_swift_dir('test-server2.pid')
@ -850,16 +850,16 @@ class TestServer(unittest.TestCase):
running_pids = server.get_running_pids()
# only thing-doer.pid, 1
self.assertEquals(len(running_pids), 1)
self.assert_(1 in running_pids)
self.assertTrue(1 in running_pids)
# no other pids returned
for n in (2, 3, 4):
self.assert_(n not in running_pids)
self.assertTrue(n not in running_pids)
# assert stale pids for other servers ignored
manager.os = MockOs([1]) # only thing-doer is running
running_pids = server.get_running_pids()
for f in ('thing-sayer.pid', 'other-doer.pid', 'other-sayer.pid'):
# other server pid files persist
self.assert_(os.path.exists, os.path.join(t, f))
self.assertTrue(os.path.exists, os.path.join(t, f))
# verify that servers are in fact not running
for server_name in ('thing-sayer', 'other-doer', 'other-sayer'):
server = manager.Server(server_name, run_dir=t)
@ -868,7 +868,7 @@ class TestServer(unittest.TestCase):
# and now all OTHER pid files are cleaned out
all_pids = os.listdir(t)
self.assertEquals(len(all_pids), 1)
self.assert_(os.path.exists(os.path.join(t, 'thing-doer.pid')))
self.assertTrue(os.path.exists(os.path.join(t, 'thing-doer.pid')))
def test_kill_running_pids(self):
pid_files = (
@ -894,16 +894,16 @@ class TestServer(unittest.TestCase):
# test kill one pid
pids = server.kill_running_pids()
self.assertEquals(len(pids), 1)
self.assert_(1 in pids)
self.assertTrue(1 in pids)
self.assertEquals(manager.os.pid_sigs[1], [signal.SIGTERM])
# reset os mock
manager.os = MockOs([1])
# test shutdown
self.assert_('object-server' in
manager.GRACEFUL_SHUTDOWN_SERVERS)
self.assertTrue('object-server' in
manager.GRACEFUL_SHUTDOWN_SERVERS)
pids = server.kill_running_pids(graceful=True)
self.assertEquals(len(pids), 1)
self.assert_(1 in pids)
self.assertTrue(1 in pids)
self.assertEquals(manager.os.pid_sigs[1], [signal.SIGHUP])
# start up other servers
manager.os = MockOs([11, 12])
@ -914,11 +914,11 @@ class TestServer(unittest.TestCase):
pids = server.kill_running_pids(graceful=True)
self.assertEquals(len(pids), 2)
for pid in (11, 12):
self.assert_(pid in pids)
self.assertTrue(pid in pids)
self.assertEquals(manager.os.pid_sigs[pid],
[signal.SIGTERM])
# and the other pid is of course not signaled
self.assert_(1 not in manager.os.pid_sigs)
self.assertTrue(1 not in manager.os.pid_sigs)
def test_status(self):
conf_files = (
@ -962,7 +962,7 @@ class TestServer(unittest.TestCase):
output = pop_stream(f).strip().splitlines()
self.assertEquals(len(output), 4)
for line in output:
self.assert_('test-server running' in line)
self.assertTrue('test-server running' in line)
# test get single server by number
with temptree([], []) as t:
manager.PROC_DIR = t
@ -970,9 +970,9 @@ class TestServer(unittest.TestCase):
output = pop_stream(f).strip().splitlines()
self.assertEquals(len(output), 1)
line = output[0]
self.assert_('test-server running' in line)
self.assertTrue('test-server running' in line)
conf_four = self.join_swift_dir(conf_files[3])
self.assert_('4 - %s' % conf_four in line)
self.assertTrue('4 - %s' % conf_four in line)
# test some servers not running
manager.os = MockOs([1, 2, 3])
proc_files = (
@ -987,7 +987,7 @@ class TestServer(unittest.TestCase):
output = pop_stream(f).strip().splitlines()
self.assertEquals(len(output), 3)
for line in output:
self.assert_('test-server running' in line)
self.assertTrue('test-server running' in line)
# test single server not running
manager.os = MockOs([1, 2])
proc_files = (
@ -1001,16 +1001,16 @@ class TestServer(unittest.TestCase):
output = pop_stream(f).strip().splitlines()
self.assertEquals(len(output), 1)
line = output[0]
self.assert_('not running' in line)
self.assertTrue('not running' in line)
conf_three = self.join_swift_dir(conf_files[2])
self.assert_(conf_three in line)
self.assertTrue(conf_three in line)
# test no running pids
manager.os = MockOs([])
with temptree([], []) as t:
manager.PROC_DIR = t
self.assertEquals(server.status(), 1)
output = pop_stream(f).lower()
self.assert_('no test-server running' in output)
self.assertTrue('no test-server running' in output)
# test use provided pids
pids = {
1: '1.pid',
@ -1028,7 +1028,7 @@ class TestServer(unittest.TestCase):
output = pop_stream(f).strip().splitlines()
self.assertEquals(len(output), 2)
for line in output:
self.assert_('test-server running' in line)
self.assertTrue('test-server running' in line)
finally:
sys.stdout = old_stdout
@ -1078,11 +1078,11 @@ class TestServer(unittest.TestCase):
server.spawn(conf_file)
# test pid file
pid_file = self.join_run_dir('test-server.pid')
self.assert_(os.path.exists(pid_file))
self.assertTrue(os.path.exists(pid_file))
pid_on_disk = int(open(pid_file).read().strip())
self.assertEquals(pid_on_disk, 1)
# assert procs args
self.assert_(server.procs)
self.assertTrue(server.procs)
self.assertEquals(len(server.procs), 1)
proc = server.procs[0]
expected_args = [
@ -1102,7 +1102,7 @@ class TestServer(unittest.TestCase):
server = manager.Server('test', run_dir=t)
# test server run once
server.spawn(conf1, once=True)
self.assert_(server.procs)
self.assertTrue(server.procs)
self.assertEquals(len(server.procs), 1)
proc = server.procs[0]
expected_args = ['swift-test-server', conf1, 'once']
@ -1111,7 +1111,7 @@ class TestServer(unittest.TestCase):
self.assertEquals(proc.stderr, proc.stdout)
# test server not daemon
server.spawn(conf2, daemon=False)
self.assert_(server.procs)
self.assertTrue(server.procs)
self.assertEquals(len(server.procs), 2)
proc = server.procs[1]
expected_args = ['swift-test-server', conf2, 'verbose']
@ -1121,17 +1121,17 @@ class TestServer(unittest.TestCase):
self.assertEquals(proc.stderr, None)
# test server wait
server.spawn(conf3, wait=False)
self.assert_(server.procs)
self.assertTrue(server.procs)
self.assertEquals(len(server.procs), 3)
proc = server.procs[2]
# assert stdout is /dev/null
self.assert_(isinstance(proc.stdout, file))
self.assertTrue(isinstance(proc.stdout, file))
self.assertEquals(proc.stdout.name, os.devnull)
self.assertEquals(proc.stdout.mode, 'w+b')
self.assertEquals(proc.stderr, proc.stdout)
# test not daemon over-rides wait
server.spawn(conf4, wait=False, daemon=False, once=True)
self.assert_(server.procs)
self.assertTrue(server.procs)
self.assertEquals(len(server.procs), 4)
proc = server.procs[3]
expected_args = ['swift-test-server', conf4, 'once',
@ -1230,24 +1230,24 @@ class TestServer(unittest.TestCase):
status = server.wait()
self.assertEquals(status, 0)
# wait should return before process exits
self.assert_(proc.isAlive())
self.assertTrue(proc.isAlive())
self.assertFalse(proc.finished)
self.assert_(proc.finished) # make sure it did finish...
self.assertTrue(proc.finished) # make sure it did finish
# test output kwarg prints subprocess output
with MockProcess() as proc:
server.procs = [proc]
status = server.wait(output=True)
output = pop_stream(f)
self.assert_('mock process started' in output)
self.assert_('setup complete' in output)
self.assertTrue('mock process started' in output)
self.assertTrue('setup complete' in output)
# make sure we don't get prints after stdout was closed
self.assert_('mock process finished' not in output)
self.assertTrue('mock process finished' not in output)
# test process which fails to start
with MockProcess(fail_to_start=True) as proc:
server.procs = [proc]
status = server.wait()
self.assertEquals(status, 1)
self.assert_('failed' in pop_stream(f))
self.assertTrue('failed' in pop_stream(f))
# test multiple procs
procs = [MockProcess(delay=.5) for i in range(3)]
for proc in procs:
@ -1256,7 +1256,7 @@ class TestServer(unittest.TestCase):
status = server.wait()
self.assertEquals(status, 0)
for proc in procs:
self.assert_(proc.isAlive())
self.assertTrue(proc.isAlive())
for proc in procs:
proc.join()
finally:
@ -1287,7 +1287,7 @@ class TestServer(unittest.TestCase):
for fail in (False, True, True):
procs.append(MockProcess(fail=fail))
server.procs = procs
self.assert_(server.interact() > 0)
self.assertTrue(server.interact() > 0)
def test_launch(self):
# stubs
@ -1352,13 +1352,13 @@ class TestServer(unittest.TestCase):
# can't start server if it's already running
self.assertFalse(server.launch())
output = pop_stream(f)
self.assert_('running' in output)
self.assertTrue('running' in output)
conf_file = self.join_swift_dir(
'proxy-server.conf')
self.assert_(conf_file in output)
self.assertTrue(conf_file in output)
pid_file = self.join_run_dir('proxy-server/2.pid')
self.assert_(pid_file in output)
self.assert_('already started' in output)
self.assertTrue(pid_file in output)
self.assertTrue('already started' in output)
# no running pids
manager.os = MockOs([])
with temptree([], []) as proc_dir:
@ -1380,8 +1380,8 @@ class TestServer(unittest.TestCase):
}
self.assertEquals(mock_spawn.kwargs, [expected])
output = pop_stream(f)
self.assert_('Starting' in output)
self.assert_('once' not in output)
self.assertTrue('Starting' in output)
self.assertTrue('once' not in output)
# test multi-server kwarg once
server = manager.Server('object-replicator')
with temptree([], []) as proc_dir:
@ -1430,8 +1430,9 @@ class TestServer(unittest.TestCase):
'blah')])
server.spawn = mock_spawn
self.assertEquals(server.launch(), {})
self.assert_('swift-auth-server does not exist' in
pop_stream(f))
self.assertTrue(
'swift-auth-server does not exist' in
pop_stream(f))
finally:
sys.stdout = old_stdout
@ -1461,7 +1462,7 @@ class TestServer(unittest.TestCase):
pids = server.stop()
self.assertEquals(len(pids), 4)
for pid in (1, 2, 3, 4):
self.assert_(pid in pids)
self.assertTrue(pid in pids)
self.assertEquals(manager.os.pid_sigs[pid],
[signal.SIGTERM])
conf1 = self.join_swift_dir('account-reaper/1.conf')
@ -1473,7 +1474,7 @@ class TestServer(unittest.TestCase):
pids = server.stop()
self.assertEquals(len(pids), 2)
for pid in (3, 4):
self.assert_(pid in pids)
self.assertTrue(pid in pids)
self.assertEquals(manager.os.pid_sigs[pid],
[signal.SIGTERM])
self.assertFalse(os.path.exists(conf1))
@ -1485,7 +1486,7 @@ class TestServer(unittest.TestCase):
expected = {
3: conf3,
}
self.assert_(pids, expected)
self.assertTrue(pids, expected)
self.assertEquals(manager.os.pid_sigs[3], [signal.SIGTERM])
self.assertFalse(os.path.exists(conf4))
self.assertFalse(os.path.exists(conf3))
@ -1497,58 +1498,58 @@ class TestManager(unittest.TestCase):
m = manager.Manager(['test'])
self.assertEquals(len(m.servers), 1)
server = m.servers.pop()
self.assert_(isinstance(server, manager.Server))
self.assertTrue(isinstance(server, manager.Server))
self.assertEquals(server.server, 'test-server')
# test multi-server and simple dedupe
servers = ['object-replicator', 'object-auditor', 'object-replicator']
m = manager.Manager(servers)
self.assertEquals(len(m.servers), 2)
for server in m.servers:
self.assert_(server.server in servers)
self.assertTrue(server.server in servers)
# test all
m = manager.Manager(['all'])
self.assertEquals(len(m.servers), len(manager.ALL_SERVERS))
for server in m.servers:
self.assert_(server.server in manager.ALL_SERVERS)
self.assertTrue(server.server in manager.ALL_SERVERS)
# test main
m = manager.Manager(['main'])
self.assertEquals(len(m.servers), len(manager.MAIN_SERVERS))
for server in m.servers:
self.assert_(server.server in manager.MAIN_SERVERS)
self.assertTrue(server.server in manager.MAIN_SERVERS)
# test rest
m = manager.Manager(['rest'])
self.assertEquals(len(m.servers), len(manager.REST_SERVERS))
for server in m.servers:
self.assert_(server.server in manager.REST_SERVERS)
self.assertTrue(server.server in manager.REST_SERVERS)
# test main + rest == all
m = manager.Manager(['main', 'rest'])
self.assertEquals(len(m.servers), len(manager.ALL_SERVERS))
for server in m.servers:
self.assert_(server.server in manager.ALL_SERVERS)
self.assertTrue(server.server in manager.ALL_SERVERS)
# test dedupe
m = manager.Manager(['main', 'rest', 'proxy', 'object',
'container', 'account'])
self.assertEquals(len(m.servers), len(manager.ALL_SERVERS))
for server in m.servers:
self.assert_(server.server in manager.ALL_SERVERS)
self.assertTrue(server.server in manager.ALL_SERVERS)
# test glob
m = manager.Manager(['object-*'])
object_servers = [s for s in manager.ALL_SERVERS if
s.startswith('object')]
self.assertEquals(len(m.servers), len(object_servers))
for s in m.servers:
self.assert_(str(s) in object_servers)
self.assertTrue(str(s) in object_servers)
m = manager.Manager(['*-replicator'])
replicators = [s for s in manager.ALL_SERVERS if
s.endswith('replicator')]
for s in m.servers:
self.assert_(str(s) in replicators)
self.assertTrue(str(s) in replicators)
def test_iter(self):
m = manager.Manager(['all'])
self.assertEquals(len(list(m)), len(manager.ALL_SERVERS))
for server in m:
self.assert_(server.server in manager.ALL_SERVERS)
self.assertTrue(server.server in manager.ALL_SERVERS)
def test_status(self):
class MockServer(object):
@ -1682,7 +1683,7 @@ class TestManager(unittest.TestCase):
for server in init.servers:
self.assertEquals(len(server.called['launch']), 1)
called_kwargs = server.called['launch'][0]
self.assert_('wait' in called_kwargs)
self.assertTrue('wait' in called_kwargs)
self.assertFalse(called_kwargs['wait'])
self.assertFalse(server.called['wait'])
# test wait with once option
@ -1692,10 +1693,10 @@ class TestManager(unittest.TestCase):
for server in init.servers:
self.assertEquals(len(server.called['launch']), 1)
called_kwargs = server.called['launch'][0]
self.assert_('wait' in called_kwargs)
self.assertTrue('wait' in called_kwargs)
self.assertFalse(called_kwargs['wait'])
self.assert_('once' in called_kwargs)
self.assert_(called_kwargs['once'])
self.assertTrue('once' in called_kwargs)
self.assertTrue(called_kwargs['once'])
self.assertFalse(server.called['wait'])
finally:
manager.Server = orig_swift_server
@ -1897,8 +1898,8 @@ class TestManager(unittest.TestCase):
try:
m = _orig_manager(['auth'])
for server in m.servers:
self.assert_(server.server in
manager.GRACEFUL_SHUTDOWN_SERVERS)
self.assertTrue(server.server in
manager.GRACEFUL_SHUTDOWN_SERVERS)
manager.Manager = MockManager
status = m.reload()
self.assertEquals(status, 0)
@ -1912,8 +1913,8 @@ class TestManager(unittest.TestCase):
m = _orig_manager(['*-server'])
self.assertEquals(len(m.servers), 4)
for server in m.servers:
self.assert_(server.server in
manager.GRACEFUL_SHUTDOWN_SERVERS)
self.assertTrue(server.server in
manager.GRACEFUL_SHUTDOWN_SERVERS)
manager.Manager = MockManager
status = m.reload(graceful=False)
self.assertEquals(status, 0)
@ -1952,8 +1953,8 @@ class TestManager(unittest.TestCase):
def test_list_commands(self):
for cmd, help in manager.Manager.list_commands():
method = getattr(manager.Manager, cmd.replace('-', '_'), None)
self.assert_(method, '%s is not a command' % cmd)
self.assert_(getattr(method, 'publicly_accessible', False))
self.assertTrue(method, '%s is not a command' % cmd)
self.assertTrue(getattr(method, 'publicly_accessible', False))
self.assertEquals(method.__doc__.strip(), help)
def test_run_command(self):

View File

@ -177,7 +177,7 @@ class TestMemcached(unittest.TestCase):
key = uuid4().hex
for conn in memcache_client._get_conns(key):
peeripport = '%s:%s' % conn[2].getpeername()
self.assert_(peeripport in (sock1ipport, sock2ipport))
self.assertTrue(peeripport in (sock1ipport, sock2ipport))
if peeripport == sock1ipport:
one = False
if peeripport == sock2ipport:
@ -200,7 +200,7 @@ class TestMemcached(unittest.TestCase):
# we should expect to have unicode
self.assertEquals(
memcache_client.get('some_key'), ['simple str', u'utf8 str éà'])
self.assert_(float(mock.cache.values()[0][1]) == 0)
self.assertTrue(float(mock.cache.values()[0][1]) == 0)
memcache_client.set('some_key', [1, 2, 3], timeout=10)
self.assertEquals(mock.cache.values()[0][1], '10')
memcache_client.set('some_key', [1, 2, 3], time=20)
@ -209,9 +209,11 @@ class TestMemcached(unittest.TestCase):
sixtydays = 60 * 24 * 60 * 60
esttimeout = time.time() + sixtydays
memcache_client.set('some_key', [1, 2, 3], timeout=sixtydays)
self.assert_(-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
memcache_client.set('some_key', [1, 2, 3], time=sixtydays)
self.assert_(-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
def test_incr(self):
memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'])
@ -247,7 +249,8 @@ class TestMemcached(unittest.TestCase):
esttimeout = time.time() + fiftydays
memcache_client.incr('some_key', delta=5, time=fiftydays)
self.assertEquals(memcache_client.get('some_key'), '5')
self.assert_(-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
memcache_client.delete('some_key')
self.assertEquals(memcache_client.get('some_key'), None)
memcache_client.incr('some_key', delta=5)
@ -326,8 +329,10 @@ class TestMemcached(unittest.TestCase):
memcache_client.set_multi(
{'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key',
timeout=fortydays)
self.assert_(-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assert_(-1 <= float(mock.cache.values()[1][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[1][1]) - esttimeout <= 1)
self.assertEquals(memcache_client.get_multi(
('some_key2', 'some_key1', 'not_exists'), 'multi_key'),
[[4, 5, 6], [1, 2, 3], None])

View File

@ -64,10 +64,10 @@ class TestSplice(unittest.TestCase):
def test_flags(self):
'''Test flag attribute availability'''
self.assert_(hasattr(splice, 'SPLICE_F_MOVE'))
self.assert_(hasattr(splice, 'SPLICE_F_NONBLOCK'))
self.assert_(hasattr(splice, 'SPLICE_F_MORE'))
self.assert_(hasattr(splice, 'SPLICE_F_GIFT'))
self.assertTrue(hasattr(splice, 'SPLICE_F_MOVE'))
self.assertTrue(hasattr(splice, 'SPLICE_F_NONBLOCK'))
self.assertTrue(hasattr(splice, 'SPLICE_F_MORE'))
self.assertTrue(hasattr(splice, 'SPLICE_F_GIFT'))
@mock.patch('swift.common.splice.splice._c_splice', None)
def test_available(self):

View File

@ -54,8 +54,8 @@ class TestStoragePolicies(unittest.TestCase):
f(*args, **kwargs)
except exc_class as err:
err_msg = str(err)
self.assert_(message in err_msg, 'Error message %r did not '
'have expected substring %r' % (err_msg, message))
self.assertTrue(message in err_msg, 'Error message %r did not '
'have expected substring %r' % (err_msg, message))
else:
self.fail('%r did not raise %s' % (message, exc_class.__name__))
@ -133,11 +133,11 @@ class TestStoragePolicies(unittest.TestCase):
# test class functions
default_policy = POLICIES.default
self.assert_(default_policy.is_default)
self.assertTrue(default_policy.is_default)
zero_policy = POLICIES.get_by_index(0)
self.assert_(zero_policy.idx == 0)
self.assertTrue(zero_policy.idx == 0)
zero_policy_by_name = POLICIES.get_by_name(zero_policy.name)
self.assert_(zero_policy_by_name.idx == 0)
self.assertTrue(zero_policy_by_name.idx == 0)
def test_storage_policy_repr(self):
test_policies = [StoragePolicy(0, 'aay', True),
@ -148,24 +148,25 @@ class TestStoragePolicies(unittest.TestCase):
policies = StoragePolicyCollection(test_policies)
for policy in policies:
policy_repr = repr(policy)
self.assert_(policy.__class__.__name__ in policy_repr)
self.assert_('is_default=%s' % policy.is_default in policy_repr)
self.assert_('is_deprecated=%s' % policy.is_deprecated in
policy_repr)
self.assert_(policy.name in policy_repr)
self.assertTrue(policy.__class__.__name__ in policy_repr)
self.assertTrue('is_default=%s' % policy.is_default in policy_repr)
self.assertTrue('is_deprecated=%s' % policy.is_deprecated in
policy_repr)
self.assertTrue(policy.name in policy_repr)
if policy.policy_type == EC_POLICY:
self.assert_('ec_type=%s' % policy.ec_type in policy_repr)
self.assert_('ec_ndata=%s' % policy.ec_ndata in policy_repr)
self.assert_('ec_nparity=%s' %
policy.ec_nparity in policy_repr)
self.assert_('ec_segment_size=%s' %
policy.ec_segment_size in policy_repr)
self.assertTrue('ec_type=%s' % policy.ec_type in policy_repr)
self.assertTrue('ec_ndata=%s' % policy.ec_ndata in policy_repr)
self.assertTrue('ec_nparity=%s' %
policy.ec_nparity in policy_repr)
self.assertTrue('ec_segment_size=%s' %
policy.ec_segment_size in policy_repr)
collection_repr = repr(policies)
collection_repr_lines = collection_repr.splitlines()
self.assert_(policies.__class__.__name__ in collection_repr_lines[0])
self.assertTrue(
policies.__class__.__name__ in collection_repr_lines[0])
self.assertEqual(len(policies), len(collection_repr_lines[1:-1]))
for policy, line in zip(policies, collection_repr_lines[1:-1]):
self.assert_(repr(policy) in line)
self.assertTrue(repr(policy) in line)
with patch_policies(policies):
self.assertEqual(repr(POLICIES), collection_repr)
@ -362,7 +363,7 @@ class TestStoragePolicies(unittest.TestCase):
policies = parse_storage_policies(orig_conf)
self.assertEqual(policies.default, policies[1])
self.assert_(policies[0].name, 'Policy-0')
self.assertTrue(policies[0].name, 'Policy-0')
bad_conf = self._conf("""
[storage-policy:0]
@ -388,7 +389,7 @@ class TestStoragePolicies(unittest.TestCase):
policies = parse_storage_policies(good_conf)
self.assertEqual(policies.default, policies[0])
self.assert_(policies[1].is_deprecated, True)
self.assertTrue(policies[1].is_deprecated, True)
def test_parse_storage_policies(self):
# ValueError when deprecating policy 0
@ -692,8 +693,9 @@ class TestStoragePolicies(unittest.TestCase):
'Duplicate index',
]
for expected in parts:
self.assert_(expected in err_msg, '%s was not in %s' % (expected,
err_msg))
self.assertTrue(
expected in err_msg, '%s was not in %s' % (expected,
err_msg))
def test_storage_policy_ordering(self):
test_policies = StoragePolicyCollection([
@ -727,7 +729,7 @@ class TestStoragePolicies(unittest.TestCase):
ring = policies.get_object_ring(int(policy), '/path/not/used')
self.assertEqual(ring.ring_name, policy.ring_name)
self.assertTrue(policy.object_ring)
self.assert_(isinstance(policy.object_ring, NamedFakeRing))
self.assertTrue(isinstance(policy.object_ring, NamedFakeRing))
def blow_up(*args, **kwargs):
raise Exception('kaboom!')

View File

@ -58,9 +58,9 @@ class TestHeaderEnvironProxy(unittest.TestCase):
proxy['Content-Length'] = 20
proxy['Content-Type'] = 'text/plain'
proxy['Something-Else'] = 'somevalue'
self.assert_('content-length' in proxy)
self.assert_('content-type' in proxy)
self.assert_('something-else' in proxy)
self.assertTrue('content-length' in proxy)
self.assertTrue('content-type' in proxy)
self.assertTrue('something-else' in proxy)
def test_keys(self):
environ = {}
@ -103,9 +103,9 @@ class TestHeaderKeyDict(unittest.TestCase):
def test_del_contains(self):
headers = swift.common.swob.HeaderKeyDict()
headers['Content-Length'] = 0
self.assert_('Content-Length' in headers)
self.assertTrue('Content-Length' in headers)
del headers['Content-Length']
self.assert_('Content-Length' not in headers)
self.assertTrue('Content-Length' not in headers)
def test_update(self):
headers = swift.common.swob.HeaderKeyDict()
@ -279,37 +279,37 @@ class TestRange(unittest.TestCase):
6. any combination of the above
"""
self.assert_(_check_invalid_range('nonbytes=foobar,10-2'))
self.assert_(_check_invalid_range('bytes=5-3'))
self.assert_(_check_invalid_range('bytes=-'))
self.assert_(_check_invalid_range('bytes=45'))
self.assert_(_check_invalid_range('bytes=foo-bar,3-5'))
self.assert_(_check_invalid_range('bytes=4-10,45'))
self.assert_(_check_invalid_range('bytes=foobar,3-5'))
self.assert_(_check_invalid_range('bytes=nonumber-5'))
self.assert_(_check_invalid_range('bytes=nonumber'))
self.assertTrue(_check_invalid_range('nonbytes=foobar,10-2'))
self.assertTrue(_check_invalid_range('bytes=5-3'))
self.assertTrue(_check_invalid_range('bytes=-'))
self.assertTrue(_check_invalid_range('bytes=45'))
self.assertTrue(_check_invalid_range('bytes=foo-bar,3-5'))
self.assertTrue(_check_invalid_range('bytes=4-10,45'))
self.assertTrue(_check_invalid_range('bytes=foobar,3-5'))
self.assertTrue(_check_invalid_range('bytes=nonumber-5'))
self.assertTrue(_check_invalid_range('bytes=nonumber'))
class TestMatch(unittest.TestCase):
def test_match(self):
match = swift.common.swob.Match('"a", "b"')
self.assertEquals(match.tags, set(('a', 'b')))
self.assert_('a' in match)
self.assert_('b' in match)
self.assert_('c' not in match)
self.assertTrue('a' in match)
self.assertTrue('b' in match)
self.assertTrue('c' not in match)
def test_match_star(self):
match = swift.common.swob.Match('"a", "*"')
self.assert_('a' in match)
self.assert_('b' in match)
self.assert_('c' in match)
self.assertTrue('a' in match)
self.assertTrue('b' in match)
self.assertTrue('c' in match)
def test_match_noquote(self):
match = swift.common.swob.Match('a, b')
self.assertEquals(match.tags, set(('a', 'b')))
self.assert_('a' in match)
self.assert_('b' in match)
self.assert_('c' not in match)
self.assertTrue('a' in match)
self.assertTrue('b' in match)
self.assertTrue('c' not in match)
class TestAccept(unittest.TestCase):
@ -430,8 +430,8 @@ class TestRequest(unittest.TestCase):
self.assertEquals("got unexpected keyword argument 'params'",
str(e))
else:
self.assert_(False, "invalid req_environ_property "
"didn't raise error!")
self.assertTrue(False, "invalid req_environ_property "
"didn't raise error!")
# regular attribute
try:
swift.common.swob.Request.blank('/', _params_cache={'a': 'b'})
@ -439,8 +439,8 @@ class TestRequest(unittest.TestCase):
self.assertEquals("got unexpected keyword "
"argument '_params_cache'", str(e))
else:
self.assert_(False, "invalid req_environ_property "
"didn't raise error!")
self.assertTrue(False, "invalid req_environ_property "
"didn't raise error!")
# non-existent attribute
try:
swift.common.swob.Request.blank('/', params_cache={'a': 'b'})
@ -448,8 +448,8 @@ class TestRequest(unittest.TestCase):
self.assertEquals("got unexpected keyword "
"argument 'params_cache'", str(e))
else:
self.assert_(False, "invalid req_environ_property "
"didn't raise error!")
self.assertTrue(False, "invalid req_environ_property "
"didn't raise error!")
# method
try:
swift.common.swob.Request.blank(
@ -458,8 +458,8 @@ class TestRequest(unittest.TestCase):
self.assertEquals("got unexpected keyword "
"argument 'as_referer'", str(e))
else:
self.assert_(False, "invalid req_environ_property "
"didn't raise error!")
self.assertTrue(False, "invalid req_environ_property "
"didn't raise error!")
def test_blank_path_info_precedence(self):
blank = swift.common.swob.Request.blank
@ -487,7 +487,7 @@ class TestRequest(unittest.TestCase):
'wsgi.input': StringIO('')},
headers={'Content-Type': 'text/plain'}, body='hi',
body_file=body_file)
self.assert_(req.body_file is body_file)
self.assertTrue(req.body_file is body_file)
req = swift.common.swob.Request.blank(
'/', environ={'REQUEST_METHOD': 'POST',
'wsgi.input': StringIO('')},
@ -595,12 +595,12 @@ class TestRequest(unittest.TestCase):
# No request environment
resp = swift.common.swob.HTTPUnauthorized()
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
# Request environment
req = swift.common.swob.Request.blank('/')
resp = swift.common.swob.HTTPUnauthorized(request=req)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
def test_401_valid_account_path(self):
@ -612,7 +612,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/v1/account-name')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="account-name"',
resp.headers['Www-Authenticate'])
@ -620,7 +620,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/v1/account-name/c')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="account-name"',
resp.headers['Www-Authenticate'])
@ -634,7 +634,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/random')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="unknown"',
resp.headers['Www-Authenticate'])
@ -648,7 +648,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/v1.0/auth')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="unknown"',
resp.headers['Www-Authenticate'])
@ -656,7 +656,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/auth/v1.0')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="unknown"',
resp.headers['Www-Authenticate'])
@ -671,7 +671,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/auth/v1.0')
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Me realm="whatever"',
resp.headers['Www-Authenticate'])
@ -686,14 +686,14 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/v1/' + hacker)
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="%s"' % quoted_hacker,
resp.headers['Www-Authenticate'])
req = swift.common.swob.Request.blank('/v1/' + quoted_hacker)
resp = req.get_response(test_app)
self.assertEquals(resp.status_int, 401)
self.assert_('Www-Authenticate' in resp.headers)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertEquals('Swift realm="%s"' % quoted_hacker,
resp.headers['Www-Authenticate'])
@ -706,7 +706,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/')
resp = req.get_response(test_app)
self.assert_('Www-Authenticate' not in resp.headers)
self.assertTrue('Www-Authenticate' not in resp.headers)
def test_properties(self):
req = swift.common.swob.Request.blank('/hi/there', body='hi')
@ -724,15 +724,15 @@ class TestRequest(unittest.TestCase):
req.range = 'bytes=1-7'
self.assertEquals(req.range.ranges[0], (1, 7))
self.assert_('Range' in req.headers)
self.assertTrue('Range' in req.headers)
req.range = None
self.assert_('Range' not in req.headers)
self.assertTrue('Range' not in req.headers)
def test_datetime_properties(self):
req = swift.common.swob.Request.blank('/hi/there', body='hi')
req.if_unmodified_since = 0
self.assert_(isinstance(req.if_unmodified_since, datetime.datetime))
self.assertTrue(isinstance(req.if_unmodified_since, datetime.datetime))
if_unmodified_since = req.if_unmodified_since
req.if_unmodified_since = if_unmodified_since
self.assertEquals(if_unmodified_since, req.if_unmodified_since)
@ -741,9 +741,9 @@ class TestRequest(unittest.TestCase):
self.assertEquals(req.headers['If-Unmodified-Since'], 'something')
self.assertEquals(req.if_unmodified_since, None)
self.assert_('If-Unmodified-Since' in req.headers)
self.assertTrue('If-Unmodified-Since' in req.headers)
req.if_unmodified_since = None
self.assert_('If-Unmodified-Since' not in req.headers)
self.assertTrue('If-Unmodified-Since' not in req.headers)
too_big_date_list = list(datetime.datetime.max.timetuple())
too_big_date_list[0] += 1 # bump up the year
@ -991,11 +991,11 @@ class TestStatusMap(unittest.TestCase):
self.assertEquals(resp.status_int, 404)
self.assertEquals(resp.title, 'Not Found')
body = ''.join(resp({}, start_response))
self.assert_('The resource could not be found.' in body)
self.assertTrue('The resource could not be found.' in body)
self.assertEquals(response_args[0], '404 Not Found')
headers = dict(response_args[1])
self.assertEquals(headers['Content-Type'], 'text/html; charset=UTF-8')
self.assert_(int(headers['Content-Length']) > 0)
self.assertTrue(int(headers['Content-Length']) > 0)
class TestResponse(unittest.TestCase):
@ -1012,14 +1012,14 @@ class TestResponse(unittest.TestCase):
resp.location = 'something'
self.assertEquals(resp.location, 'something')
self.assert_('Location' in resp.headers)
self.assertTrue('Location' in resp.headers)
resp.location = None
self.assert_('Location' not in resp.headers)
self.assertTrue('Location' not in resp.headers)
resp.content_type = 'text/plain'
self.assert_('Content-Type' in resp.headers)
self.assertTrue('Content-Type' in resp.headers)
resp.content_type = None
self.assert_('Content-Type' not in resp.headers)
self.assertTrue('Content-Type' not in resp.headers)
def test_empty_body(self):
resp = self._get_response()
@ -1208,19 +1208,19 @@ class TestResponse(unittest.TestCase):
('0123456789112345678'
'92123456789')))
self.assert_(re.match(('--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'0-9/100\r\n\r\n0123456789\r\n'
'--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'10-19/100\r\n\r\n1123456789\r\n'
'--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'20-29/100\r\n\r\n2123456789\r\n'
'--[a-f0-9]{32}--'), content))
self.assertTrue(re.match(('--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'0-9/100\r\n\r\n0123456789\r\n'
'--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'10-19/100\r\n\r\n1123456789\r\n'
'--[a-f0-9]{32}\r\n'
'Content-Type: text/plain\r\n'
'Content-Range: bytes '
'20-29/100\r\n\r\n2123456789\r\n'
'--[a-f0-9]{32}--'), content))
def test_multi_response_iter(self):
def test_app(environ, start_response):
@ -1337,9 +1337,9 @@ class TestResponse(unittest.TestCase):
self.assertEquals(resp.headers['Etag'], '"hi"')
self.assertEquals(resp.etag, 'hi')
self.assert_('etag' in resp.headers)
self.assertTrue('etag' in resp.headers)
resp.etag = None
self.assert_('etag' not in resp.headers)
self.assertTrue('etag' not in resp.headers)
def test_host_url_default(self):
resp = self._get_response()

View File

@ -944,23 +944,23 @@ class TestUtils(unittest.TestCase):
testdir_base = mkdtemp()
testroot = os.path.join(testdir_base, 'mkdirs')
try:
self.assert_(not os.path.exists(testroot))
self.assertTrue(not os.path.exists(testroot))
utils.mkdirs(testroot)
self.assert_(os.path.exists(testroot))
self.assertTrue(os.path.exists(testroot))
utils.mkdirs(testroot)
self.assert_(os.path.exists(testroot))
self.assertTrue(os.path.exists(testroot))
rmtree(testroot, ignore_errors=1)
testdir = os.path.join(testroot, 'one/two/three')
self.assert_(not os.path.exists(testdir))
self.assertTrue(not os.path.exists(testdir))
utils.mkdirs(testdir)
self.assert_(os.path.exists(testdir))
self.assertTrue(os.path.exists(testdir))
utils.mkdirs(testdir)
self.assert_(os.path.exists(testdir))
self.assertTrue(os.path.exists(testdir))
rmtree(testroot, ignore_errors=1)
open(testroot, 'wb').close()
self.assert_(not os.path.exists(testdir))
self.assertTrue(not os.path.exists(testdir))
self.assertRaises(OSError, utils.mkdirs, testdir)
os.unlink(testroot)
finally:
@ -1083,14 +1083,14 @@ class TestUtils(unittest.TestCase):
pass
except Exception:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
got_exc = False
try:
for line in lfo.xreadlines():
pass
except Exception:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
self.assertRaises(IOError, lfo.read)
self.assertRaises(IOError, lfo.read, 1024)
self.assertRaises(IOError, lfo.readline)
@ -1105,7 +1105,7 @@ class TestUtils(unittest.TestCase):
self.assertEquals(conf, conf_file)
# assert defaults
self.assertEquals(options['verbose'], False)
self.assert_('once' not in options)
self.assertTrue('once' not in options)
# assert verbose as option
conf, options = utils.parse_options(test_args=[conf_file, '-v'])
self.assertEquals(options['verbose'], True)
@ -1132,14 +1132,14 @@ class TestUtils(unittest.TestCase):
utils.sys.stderr = stde
self.assertRaises(SystemExit, utils.parse_options, once=True,
test_args=[])
self.assert_('missing config' in stdo.getvalue())
self.assertTrue('missing config' in stdo.getvalue())
# verify conf file must exist, context manager will delete temp file
with NamedTemporaryFile() as f:
conf_file = f.name
self.assertRaises(SystemExit, utils.parse_options, once=True,
test_args=[conf_file])
self.assert_('unable to locate' in stdo.getvalue())
self.assertTrue('unable to locate' in stdo.getvalue())
# reset stdio
utils.sys.stdout = orig_stdout
@ -1294,60 +1294,60 @@ class TestUtils(unittest.TestCase):
for en in (errno.EIO, errno.ENOSPC):
log_exception(OSError(en, 'my %s error message' % en))
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('my %s error message' % en in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('my %s error message' % en in log_msg)
# unfiltered
log_exception(OSError())
self.assert_('Traceback' in strip_value(sio))
self.assertTrue('Traceback' in strip_value(sio))
# test socket.error
log_exception(socket.error(errno.ECONNREFUSED,
'my error message'))
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('errno.ECONNREFUSED message test' not in log_msg)
self.assert_('Connection refused' in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('errno.ECONNREFUSED message test' not in log_msg)
self.assertTrue('Connection refused' in log_msg)
log_exception(socket.error(errno.EHOSTUNREACH,
'my error message'))
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('my error message' not in log_msg)
self.assert_('Host unreachable' in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('my error message' not in log_msg)
self.assertTrue('Host unreachable' in log_msg)
log_exception(socket.error(errno.ETIMEDOUT, 'my error message'))
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('my error message' not in log_msg)
self.assert_('Connection timeout' in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('my error message' not in log_msg)
self.assertTrue('Connection timeout' in log_msg)
# unfiltered
log_exception(socket.error(0, 'my error message'))
log_msg = strip_value(sio)
self.assert_('Traceback' in log_msg)
self.assert_('my error message' in log_msg)
self.assertTrue('Traceback' in log_msg)
self.assertTrue('my error message' in log_msg)
# test eventlet.Timeout
connection_timeout = ConnectionTimeout(42, 'my error message')
log_exception(connection_timeout)
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('ConnectionTimeout' in log_msg)
self.assert_('(42s)' in log_msg)
self.assert_('my error message' not in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('ConnectionTimeout' in log_msg)
self.assertTrue('(42s)' in log_msg)
self.assertTrue('my error message' not in log_msg)
connection_timeout.cancel()
message_timeout = MessageTimeout(42, 'my error message')
log_exception(message_timeout)
log_msg = strip_value(sio)
self.assert_('Traceback' not in log_msg)
self.assert_('MessageTimeout' in log_msg)
self.assert_('(42s)' in log_msg)
self.assert_('my error message' in log_msg)
self.assertTrue('Traceback' not in log_msg)
self.assertTrue('MessageTimeout' in log_msg)
self.assertTrue('(42s)' in log_msg)
self.assertTrue('my error message' in log_msg)
message_timeout.cancel()
# test unhandled
log_exception(Exception('my error message'))
log_msg = strip_value(sio)
self.assert_('Traceback' in log_msg)
self.assert_('my error message' in log_msg)
self.assertTrue('Traceback' in log_msg)
self.assertTrue('my error message' in log_msg)
finally:
logger.logger.removeHandler(handler)
@ -1425,19 +1425,19 @@ class TestUtils(unittest.TestCase):
self.assertFalse(logger.txn_id)
logger.error('my error message')
log_msg = strip_value(sio)
self.assert_('my error message' in log_msg)
self.assert_('txn' not in log_msg)
self.assertTrue('my error message' in log_msg)
self.assertTrue('txn' not in log_msg)
logger.txn_id = '12345'
logger.error('test')
log_msg = strip_value(sio)
self.assert_('txn' in log_msg)
self.assert_('12345' in log_msg)
self.assertTrue('txn' in log_msg)
self.assertTrue('12345' in log_msg)
# test no txn on info message
self.assertEquals(logger.txn_id, '12345')
logger.info('test')
log_msg = strip_value(sio)
self.assert_('txn' not in log_msg)
self.assert_('12345' not in log_msg)
self.assertTrue('txn' not in log_msg)
self.assertTrue('12345' not in log_msg)
# test txn already in message
self.assertEquals(logger.txn_id, '12345')
logger.warn('test 12345 test')
@ -1445,25 +1445,25 @@ class TestUtils(unittest.TestCase):
# Test multi line collapsing
logger.error('my\nerror\nmessage')
log_msg = strip_value(sio)
self.assert_('my#012error#012message' in log_msg)
self.assertTrue('my#012error#012message' in log_msg)
# test client_ip
self.assertFalse(logger.client_ip)
logger.error('my error message')
log_msg = strip_value(sio)
self.assert_('my error message' in log_msg)
self.assert_('client_ip' not in log_msg)
self.assertTrue('my error message' in log_msg)
self.assertTrue('client_ip' not in log_msg)
logger.client_ip = '1.2.3.4'
logger.error('test')
log_msg = strip_value(sio)
self.assert_('client_ip' in log_msg)
self.assert_('1.2.3.4' in log_msg)
self.assertTrue('client_ip' in log_msg)
self.assertTrue('1.2.3.4' in log_msg)
# test no client_ip on info message
self.assertEquals(logger.client_ip, '1.2.3.4')
logger.info('test')
log_msg = strip_value(sio)
self.assert_('client_ip' not in log_msg)
self.assert_('1.2.3.4' not in log_msg)
self.assertTrue('client_ip' not in log_msg)
self.assertTrue('1.2.3.4' not in log_msg)
# test client_ip (and txn) already in message
self.assertEquals(logger.client_ip, '1.2.3.4')
logger.warn('test 1.2.3.4 test 12345')
@ -1486,8 +1486,8 @@ class TestUtils(unittest.TestCase):
def test_whataremyips(self):
myips = utils.whataremyips()
self.assert_(len(myips) > 1)
self.assert_('127.0.0.1' in myips)
self.assertTrue(len(myips) > 1)
self.assertTrue('127.0.0.1' in myips)
def test_whataremyips_bind_to_all(self):
for any_addr in ('0.0.0.0', '0000:0000:0000:0000:0000:0000:0000:0000',
@ -1495,8 +1495,8 @@ class TestUtils(unittest.TestCase):
# Wacky parse-error input produces all IPs
'I am a bear'):
myips = utils.whataremyips(any_addr)
self.assert_(len(myips) > 1)
self.assert_('127.0.0.1' in myips)
self.assertTrue(len(myips) > 1)
self.assertTrue('127.0.0.1' in myips)
def test_whataremyips_bind_ip_specific(self):
self.assertEqual(['1.2.3.4'], utils.whataremyips('1.2.3.4'))
@ -1556,9 +1556,9 @@ class TestUtils(unittest.TestCase):
utils.HASH_PATH_PREFIX = _prefix
def test_load_libc_function(self):
self.assert_(callable(
self.assertTrue(callable(
utils.load_libc_function('printf')))
self.assert_(callable(
self.assertTrue(callable(
utils.load_libc_function('some_not_real_function')))
self.assertRaises(AttributeError,
utils.load_libc_function, 'some_not_real_function',
@ -1721,7 +1721,7 @@ log_name = %(yarr)s'''
# exercise the code
utils.drop_privileges(user)
for func in required_func_calls:
self.assert_(utils.os.called_funcs[func])
self.assertTrue(utils.os.called_funcs[func])
import pwd
self.assertEquals(pwd.getpwnam(user)[5], utils.os.environ['HOME'])
@ -1736,7 +1736,7 @@ log_name = %(yarr)s'''
self.assertFalse(utils.os.called_funcs.get(func, False))
utils.drop_privileges(user)
for func in required_func_calls:
self.assert_(utils.os.called_funcs[func])
self.assertTrue(utils.os.called_funcs[func])
def test_drop_privileges_no_call_setsid(self):
user = getuser()
@ -1749,9 +1749,9 @@ log_name = %(yarr)s'''
# exercise the code
utils.drop_privileges(user, call_setsid=False)
for func in required_func_calls:
self.assert_(utils.os.called_funcs[func])
self.assertTrue(utils.os.called_funcs[func])
for func in bad_func_calls:
self.assert_(func not in utils.os.called_funcs)
self.assertTrue(func not in utils.os.called_funcs)
@reset_logger_state
def test_capture_stdio(self):
@ -1767,10 +1767,12 @@ log_name = %(yarr)s'''
# basic test
utils.capture_stdio(logger)
self.assert_(utils.sys.excepthook is not None)
self.assertTrue(utils.sys.excepthook is not None)
self.assertEquals(utils.os.closed_fds, utils.sys.stdio_fds)
self.assert_(isinstance(utils.sys.stdout, utils.LoggerFileObject))
self.assert_(isinstance(utils.sys.stderr, utils.LoggerFileObject))
self.assertTrue(
isinstance(utils.sys.stdout, utils.LoggerFileObject))
self.assertTrue(
isinstance(utils.sys.stderr, utils.LoggerFileObject))
# reset; test same args, but exc when trying to close stdio
utils.os = MockOs(raise_funcs=('dup2',))
@ -1778,10 +1780,12 @@ log_name = %(yarr)s'''
# test unable to close stdio
utils.capture_stdio(logger)
self.assert_(utils.sys.excepthook is not None)
self.assertTrue(utils.sys.excepthook is not None)
self.assertEquals(utils.os.closed_fds, [])
self.assert_(isinstance(utils.sys.stdout, utils.LoggerFileObject))
self.assert_(isinstance(utils.sys.stderr, utils.LoggerFileObject))
self.assertTrue(
isinstance(utils.sys.stdout, utils.LoggerFileObject))
self.assertTrue(
isinstance(utils.sys.stderr, utils.LoggerFileObject))
# reset; test some other args
utils.os = MockOs()
@ -1791,7 +1795,7 @@ log_name = %(yarr)s'''
# test console log
utils.capture_stdio(logger, capture_stdout=False,
capture_stderr=False)
self.assert_(utils.sys.excepthook is not None)
self.assertTrue(utils.sys.excepthook is not None)
# when logging to console, stderr remains open
self.assertEquals(utils.os.closed_fds, utils.sys.stdio_fds[:2])
reset_loggers()
@ -1814,7 +1818,7 @@ log_name = %(yarr)s'''
logger = utils.get_logger(None, log_to_console=True)
console_handlers = [h for h in logger.logger.handlers if
isinstance(h, logging.StreamHandler)]
self.assert_(console_handlers)
self.assertTrue(console_handlers)
# make sure you can't have two console handlers
self.assertEquals(len(console_handlers), 1)
old_handler = console_handlers[0]
@ -1970,7 +1974,7 @@ log_name = %(yarr)s'''
f3 = os.path.join(t, 'folder/sub/2.txt')
f4 = os.path.join(t, 'folder2/3.txt')
for f in [f1, f2, f3, f4]:
self.assert_(f in folder_texts)
self.assertTrue(f in folder_texts)
def test_search_tree_with_directory_ext_match(self):
files = (
@ -1990,7 +1994,7 @@ log_name = %(yarr)s'''
self.assertEquals(len(conf_dirs), 4)
for i in range(4):
conf_dir = os.path.join(t, 'object-server/%d.conf.d' % (i + 1))
self.assert_(conf_dir in conf_dirs)
self.assertTrue(conf_dir in conf_dirs)
def test_search_tree_conf_dir_with_named_conf_match(self):
files = (
@ -2046,7 +2050,7 @@ log_name = %(yarr)s'''
self.assertEquals(utils.remove_file(file_name), None)
with open(file_name, 'w') as f:
f.write('1')
self.assert_(os.path.exists(file_name))
self.assertTrue(os.path.exists(file_name))
self.assertEquals(utils.remove_file(file_name), None)
self.assertFalse(os.path.exists(file_name))
@ -2541,8 +2545,8 @@ cluster_dfw1 = http://dfw1.host/v1/
pass
except LockTimeout:
timedout = True
self.assert_(timedout)
self.assert_(os.path.exists(nt.name))
self.assertTrue(timedout)
self.assertTrue(os.path.exists(nt.name))
def test_ismount_path_does_not_exist(self):
tmpdir = mkdtemp()
@ -3438,8 +3442,8 @@ class TestStatsdLogging(unittest.TestCase):
logger = utils.get_logger({'log_statsd_host': 'some.host.com'},
'some-name', log_route='some-route')
# white-box construction validation
self.assert_(isinstance(logger.logger.statsd_client,
utils.StatsdClient))
self.assertTrue(isinstance(logger.logger.statsd_client,
utils.StatsdClient))
self.assertEqual(logger.logger.statsd_client._host, 'some.host.com')
self.assertEqual(logger.logger.statsd_client._port, 8125)
self.assertEqual(logger.logger.statsd_client._prefix, 'some-name.')
@ -3563,35 +3567,35 @@ class TestStatsdLogging(unittest.TestCase):
self.assertEquals(mock_controller.called, 'timing')
self.assertEquals(len(mock_controller.args), 2)
self.assertEquals(mock_controller.args[0], 'METHOD.timing')
self.assert_(mock_controller.args[1] > 0)
self.assertTrue(mock_controller.args[1] > 0)
mock_controller = MockController(404)
METHOD(mock_controller)
self.assertEquals(len(mock_controller.args), 2)
self.assertEquals(mock_controller.called, 'timing')
self.assertEquals(mock_controller.args[0], 'METHOD.timing')
self.assert_(mock_controller.args[1] > 0)
self.assertTrue(mock_controller.args[1] > 0)
mock_controller = MockController(412)
METHOD(mock_controller)
self.assertEquals(len(mock_controller.args), 2)
self.assertEquals(mock_controller.called, 'timing')
self.assertEquals(mock_controller.args[0], 'METHOD.timing')
self.assert_(mock_controller.args[1] > 0)
self.assertTrue(mock_controller.args[1] > 0)
mock_controller = MockController(416)
METHOD(mock_controller)
self.assertEquals(len(mock_controller.args), 2)
self.assertEquals(mock_controller.called, 'timing')
self.assertEquals(mock_controller.args[0], 'METHOD.timing')
self.assert_(mock_controller.args[1] > 0)
self.assertTrue(mock_controller.args[1] > 0)
mock_controller = MockController(401)
METHOD(mock_controller)
self.assertEquals(len(mock_controller.args), 2)
self.assertEquals(mock_controller.called, 'timing')
self.assertEquals(mock_controller.args[0], 'METHOD.errors.timing')
self.assert_(mock_controller.args[1] > 0)
self.assertTrue(mock_controller.args[1] > 0)
class UnsafeXrange(object):
@ -3649,14 +3653,14 @@ class TestAffinityKeyFunction(unittest.TestCase):
def test_empty_value(self):
# Empty's okay, it just means no preference
keyfn = utils.affinity_key_function("")
self.assert_(callable(keyfn))
self.assertTrue(callable(keyfn))
ids = [n['id'] for n in sorted(self.nodes, key=keyfn)]
self.assertEqual([0, 1, 2, 3, 4, 5, 6, 7], ids)
def test_all_whitespace_value(self):
# Empty's okay, it just means no preference
keyfn = utils.affinity_key_function(" \n")
self.assert_(callable(keyfn))
self.assertTrue(callable(keyfn))
ids = [n['id'] for n in sorted(self.nodes, key=keyfn)]
self.assertEqual([0, 1, 2, 3, 4, 5, 6, 7], ids)
@ -3689,23 +3693,23 @@ class TestAffinityLocalityPredicate(unittest.TestCase):
def test_empty(self):
pred = utils.affinity_locality_predicate('')
self.assert_(pred is None)
self.assertTrue(pred is None)
def test_region(self):
pred = utils.affinity_locality_predicate('r1')
self.assert_(callable(pred))
self.assertTrue(callable(pred))
ids = [n['id'] for n in self.nodes if pred(n)]
self.assertEqual([0, 1], ids)
def test_zone(self):
pred = utils.affinity_locality_predicate('r1z1')
self.assert_(callable(pred))
self.assertTrue(callable(pred))
ids = [n['id'] for n in self.nodes if pred(n)]
self.assertEqual([0], ids)
def test_multiple(self):
pred = utils.affinity_locality_predicate('r1, r3, r4z0')
self.assert_(callable(pred))
self.assertTrue(callable(pred))
ids = [n['id'] for n in self.nodes if pred(n)]
self.assertEqual([0, 1, 4, 5, 6], ids)
@ -3865,8 +3869,8 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
def assertStatMatches(self, expected_regexp, sender_fn, *args, **kwargs):
got = self._send_and_get(sender_fn, *args, **kwargs)
return self.assert_(re.search(expected_regexp, got),
[got, expected_regexp])
return self.assertTrue(re.search(expected_regexp, got),
[got, expected_regexp])
def test_methods_are_no_ops_when_not_enabled(self):
logger = utils.get_logger({

View File

@ -130,19 +130,19 @@ class TestWSGI(unittest.TestCase):
conf_file, 'proxy-server')
# verify pipeline is catch_errors -> dlo -> proxy-server
expected = swift.common.middleware.catch_errors.CatchErrorMiddleware
self.assert_(isinstance(app, expected))
self.assertTrue(isinstance(app, expected))
app = app.app
expected = swift.common.middleware.gatekeeper.GatekeeperMiddleware
self.assert_(isinstance(app, expected))
self.assertTrue(isinstance(app, expected))
app = app.app
expected = swift.common.middleware.dlo.DynamicLargeObject
self.assert_(isinstance(app, expected))
self.assertTrue(isinstance(app, expected))
app = app.app
expected = swift.proxy.server.Application
self.assert_(isinstance(app, expected))
self.assertTrue(isinstance(app, expected))
# config settings applied to app instance
self.assertEquals(0.2, app.conn_timeout)
# appconfig returns values from 'proxy-server' section
@ -206,8 +206,8 @@ class TestWSGI(unittest.TestCase):
conf_dir, 'proxy-server')
# verify pipeline is catch_errors -> proxy-server
expected = swift.common.middleware.catch_errors.CatchErrorMiddleware
self.assert_(isinstance(app, expected))
self.assert_(isinstance(app.app, swift.proxy.server.Application))
self.assertTrue(isinstance(app, expected))
self.assertTrue(isinstance(app.app, swift.proxy.server.Application))
# config settings applied to app instance
self.assertEquals(0.2, app.app.conn_timeout)
# appconfig returns values from 'proxy-server' section
@ -268,7 +268,7 @@ class TestWSGI(unittest.TestCase):
# test
sock = wsgi.get_socket(conf)
# assert
self.assert_(isinstance(sock, MockSocket))
self.assertTrue(isinstance(sock, MockSocket))
expected_socket_opts = {
socket.SOL_SOCKET: {
socket.SO_REUSEADDR: 1,
@ -380,10 +380,10 @@ class TestWSGI(unittest.TestCase):
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_('custom_pool' in kwargs)
self.assertTrue(isinstance(server_logger, wsgi.NullLogger))
self.assertTrue('custom_pool' in kwargs)
self.assertEquals(1000, kwargs['custom_pool'].size)
def test_run_server_with_latest_eventlet(self):
@ -455,7 +455,7 @@ class TestWSGI(unittest.TestCase):
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assert_(os.environ['TZ'] is not '')
self.assertTrue(os.environ['TZ'] is not '')
self.assertEquals('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
@ -468,9 +468,9 @@ class TestWSGI(unittest.TestCase):
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_('custom_pool' in kwargs)
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertTrue(isinstance(server_logger, wsgi.NullLogger))
self.assertTrue('custom_pool' in kwargs)
def test_run_server_debug(self):
config = """
@ -519,10 +519,10 @@ class TestWSGI(unittest.TestCase):
args, kwargs = mock_server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assertEqual(server_logger, None)
self.assert_('custom_pool' in kwargs)
self.assertTrue('custom_pool' in kwargs)
self.assertEquals(1000, kwargs['custom_pool'].size)
def test_appconfig_dir_ignores_hidden_files(self):
@ -1650,7 +1650,7 @@ class TestPipelineModification(unittest.TestCase):
self.assertRaises(AttributeError, getattr, filtered_app, 'foo')
# set the attribute
self.assert_(isinstance(app, FakeApp))
self.assertTrue(isinstance(app, FakeApp))
app.foo = 'bar'
self.assertEqual(filtered_app.foo, 'bar')

View File

@ -136,8 +136,8 @@ class TestAuditorMigrations(unittest.TestCase):
conn.execute('SELECT storage_policy_index '
'FROM container_stat')
except Exception as err:
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('TestContainerBrokerBeforeSPI broker class '
'was already migrated')

View File

@ -88,19 +88,19 @@ class TestContainerBroker(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 ContainerBroker.empty
broker = ContainerBroker(':memory:', account='a', container='c')
broker.initialize(Timestamp('1').internal, 0)
self.assert_(broker.empty())
self.assertTrue(broker.empty())
broker.put_object('o', Timestamp(time()).internal, 0, 'text/plain',
'd41d8cd98f00b204e9800998ecf8427e')
self.assert_(not broker.empty())
self.assertTrue(not broker.empty())
sleep(.00001)
broker.delete_object('o', Timestamp(time()).internal)
self.assert_(broker.empty())
self.assertTrue(broker.empty())
def test_reclaim(self):
broker = ContainerBroker(':memory:', account='test_account',
@ -174,7 +174,7 @@ class TestContainerBroker(unittest.TestCase):
self.assertEqual(is_deleted, False) # sanity
self.assertEqual(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__ in (TestContainerBrokerBeforeMetadata,
TestContainerBrokerBeforeXSync,
@ -192,7 +192,7 @@ class TestContainerBroker(unittest.TestCase):
self.assertEqual(is_deleted, broker.is_deleted())
self.assertEqual(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)
@ -204,7 +204,7 @@ class TestContainerBroker(unittest.TestCase):
self.assertEqual(is_deleted, broker.is_deleted())
self.assertEqual(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)
@ -480,7 +480,7 @@ class TestContainerBroker(unittest.TestCase):
broker.put_object('wrong_o', next(ts), 123, 'text/plain',
'5af83e3196bf99f440f31f2e1a6c9afe',
storage_policy_index=other_policy.idx)
self.assert_(broker.has_multiple_policies())
self.assertTrue(broker.has_multiple_policies())
@patch_policies
def test_get_policy_info(self):
@ -1572,7 +1572,7 @@ class TestContainerBrokerBeforeMetadata(ContainerBrokerMigrationMixin,
conn.execute('SELECT metadata FROM container_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):
super(TestContainerBrokerBeforeMetadata, self).tearDown()
@ -1647,7 +1647,7 @@ class TestContainerBrokerBeforeXSync(ContainerBrokerMigrationMixin,
FROM container_stat''')
except BaseException as err:
exc = err
self.assert_('no such column: x_container_sync_point1' in str(exc))
self.assertTrue('no such column: x_container_sync_point1' in str(exc))
def tearDown(self):
super(TestContainerBrokerBeforeXSync, self).tearDown()
@ -1762,7 +1762,7 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
FROM container_stat''')
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))
def tearDown(self):
super(TestContainerBrokerBeforeSPI, self).tearDown()
@ -1787,8 +1787,8 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
''').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 '
@ -1833,7 +1833,8 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
self.assertEqual(info[k], v,
'The value for %s was %r not %r' % (
k, info[k], v))
self.assert_(Timestamp(info['created_at']) > Timestamp(put_timestamp))
self.assertTrue(
Timestamp(info['created_at']) > Timestamp(put_timestamp))
self.assertNotEqual(int(info['hash'], 16), 0)
orig_hash = info['hash']
# get_replication_info
@ -1842,7 +1843,8 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
expected['count'] = expected.pop('object_count')
for k, v in expected.items():
self.assertEqual(info[k], v)
self.assert_(Timestamp(info['created_at']) > Timestamp(put_timestamp))
self.assertTrue(
Timestamp(info['created_at']) > Timestamp(put_timestamp))
self.assertEqual(info['hash'], orig_hash)
self.assertEqual(info['max_row'], 1)
self.assertEqual(info['metadata'], '')
@ -1866,8 +1868,8 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
''').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 '
@ -1881,8 +1883,8 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
''').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 '
@ -1896,7 +1898,7 @@ class TestContainerBrokerBeforeSPI(ContainerBrokerMigrationMixin,
''').fetchone()[0]
except sqlite3.OperationalError as err:
# confirm that the table does not exist yet
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 storage_policy_index '

View File

@ -606,9 +606,9 @@ class TestReconcilerUtils(unittest.TestCase):
self.assertEqual(args['headers']['X-Content-Type'],
'application/x-delete')
for header in required_headers:
self.assert_(header in args['headers'],
'%r was missing request headers %r' % (
header, args['headers']))
self.assertTrue(header in args['headers'],
'%r was missing request headers %r' % (
header, args['headers']))
def test_add_to_reconciler_queue_force(self):
mock_path = 'swift.common.direct_client.http_connect'
@ -646,9 +646,9 @@ class TestReconcilerUtils(unittest.TestCase):
self.assertEqual(args['path'],
'/.misplaced_objects/5947200/17:/a/c/o')
for header in required_headers:
self.assert_(header in args['headers'],
'%r was missing request headers %r' % (
header, args['headers']))
self.assertTrue(header in args['headers'],
'%r was missing request headers %r' % (
header, args['headers']))
def test_add_to_reconciler_queue_fails(self):
mock_path = 'swift.common.direct_client.http_connect'

View File

@ -132,9 +132,9 @@ class TestReplicatorSync(test_db_replicator.TestReplicatorSync):
debug_lines))
for metric in expected_timings:
expected = 'replicator-rpc-sync time for %s:' % metric
self.assert_(any(expected in line for line in debug_lines),
'debug timing %r was not in %r' % (
expected, debug_lines))
self.assertTrue(any(expected in line for line in debug_lines),
'debug timing %r was not in %r' % (
expected, debug_lines))
def test_sync_remote_missing(self):
broker = self._get_broker('a', 'c', node_index=0)
@ -358,7 +358,7 @@ class TestReplicatorSync(test_db_replicator.TestReplicatorSync):
name, ts, size, content_type, etag = item
remote_names.add(name)
self.assertEqual(content_type, 'content-type-new')
self.assert_('o101' in remote_names)
self.assertTrue('o101' in remote_names)
self.assertEqual(len(remote_names), 101)
self.assertEqual(remote_broker.get_info()['object_count'], 101)
@ -384,18 +384,18 @@ class TestReplicatorSync(test_db_replicator.TestReplicatorSync):
self.assertTrue(remote_broker.is_deleted())
info = broker.get_info()
remote_info = remote_broker.get_info()
self.assert_(Timestamp(remote_info['status_changed_at']) >
Timestamp(remote_info['put_timestamp']),
'remote status_changed_at (%s) is not '
'greater than put_timestamp (%s)' % (
remote_info['status_changed_at'],
remote_info['put_timestamp']))
self.assert_(Timestamp(remote_info['status_changed_at']) >
Timestamp(info['status_changed_at']),
'remote status_changed_at (%s) is not '
'greater than local status_changed_at (%s)' % (
remote_info['status_changed_at'],
info['status_changed_at']))
self.assertTrue(Timestamp(remote_info['status_changed_at']) >
Timestamp(remote_info['put_timestamp']),
'remote status_changed_at (%s) is not '
'greater than put_timestamp (%s)' % (
remote_info['status_changed_at'],
remote_info['put_timestamp']))
self.assertTrue(Timestamp(remote_info['status_changed_at']) >
Timestamp(info['status_changed_at']),
'remote status_changed_at (%s) is not '
'greater than local status_changed_at (%s)' % (
remote_info['status_changed_at'],
info['status_changed_at']))
@contextmanager
def _wrap_merge_timestamps(self, broker, calls):
@ -851,7 +851,7 @@ class TestReplicatorSync(test_db_replicator.TestReplicatorSync):
part, node = self._get_broker_part_node(broker)
daemon = self._run_once(node)
# push to remote, and third node was missing (also maybe reconciler)
self.assert_(2 < daemon.stats['rsync'] <= 3)
self.assertTrue(2 < daemon.stats['rsync'] <= 3)
# grab the rsynced instance of remote_broker
remote_broker = self._get_broker('a', 'c', node_index=1)

View File

@ -69,7 +69,7 @@ class TestContainerController(unittest.TestCase):
self.controller = container_server.ContainerController(
{'devices': self.testdir, 'mount_check': 'false'})
# some of the policy tests want at least two policies
self.assert_(len(POLICIES) > 1)
self.assertTrue(len(POLICIES) > 1)
def tearDown(self):
rmtree(os.path.dirname(self.testdir), ignore_errors=1)
@ -105,7 +105,7 @@ class TestContainerController(unittest.TestCase):
})
resp = req.get_response(self.controller)
self.assertEqual(400, resp.status_int)
self.assert_('invalid' in resp.body.lower())
self.assertTrue('invalid' in resp.body.lower())
# good policies
for policy in POLICIES:
@ -123,24 +123,24 @@ class TestContainerController(unittest.TestCase):
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'PUT'},
headers={'X-Timestamp': '0'})
resp = req.get_response(self.controller)
self.assert_(resp.status.startswith('201'))
self.assertTrue(resp.status.startswith('201'))
req = Request.blank(
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller)
self.assert_(response.status.startswith('204'))
self.assert_('x-container-read' not in response.headers)
self.assert_('x-container-write' not in response.headers)
self.assertTrue(response.status.startswith('204'))
self.assertTrue('x-container-read' not in response.headers)
self.assertTrue('x-container-write' not in response.headers)
# Ensure POSTing acls works
req = Request.blank(
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'POST'},
headers={'X-Timestamp': '1', 'X-Container-Read': '.r:*',
'X-Container-Write': 'account:user'})
resp = req.get_response(self.controller)
self.assert_(resp.status.startswith('204'))
self.assertTrue(resp.status.startswith('204'))
req = Request.blank(
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller)
self.assert_(response.status.startswith('204'))
self.assertTrue(response.status.startswith('204'))
self.assertEquals(response.headers.get('x-container-read'), '.r:*')
self.assertEquals(response.headers.get('x-container-write'),
'account:user')
@ -150,23 +150,23 @@ class TestContainerController(unittest.TestCase):
headers={'X-Timestamp': '3', 'X-Container-Read': '',
'X-Container-Write': ''})
resp = req.get_response(self.controller)
self.assert_(resp.status.startswith('204'))
self.assertTrue(resp.status.startswith('204'))
req = Request.blank(
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller)
self.assert_(response.status.startswith('204'))
self.assert_('x-container-read' not in response.headers)
self.assert_('x-container-write' not in response.headers)
self.assertTrue(response.status.startswith('204'))
self.assertTrue('x-container-read' not in response.headers)
self.assertTrue('x-container-write' not in response.headers)
# Ensure PUTing acls works
req = Request.blank(
'/sda1/p/a/c2', environ={'REQUEST_METHOD': 'PUT'},
headers={'X-Timestamp': '4', 'X-Container-Read': '.r:*',
'X-Container-Write': 'account:user'})
resp = req.get_response(self.controller)
self.assert_(resp.status.startswith('201'))
self.assertTrue(resp.status.startswith('201'))
req = Request.blank('/sda1/p/a/c2', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller)
self.assert_(response.status.startswith('204'))
self.assertTrue(response.status.startswith('204'))
self.assertEquals(response.headers.get('x-container-read'), '.r:*')
self.assertEquals(response.headers.get('x-container-write'),
'account:user')
@ -201,7 +201,7 @@ class TestContainerController(unittest.TestCase):
created_at_header = Timestamp(response.headers['x-timestamp'])
self.assertEqual(response.headers['x-timestamp'],
created_at_header.normal)
self.assert_(created_at_header >= start)
self.assertTrue(created_at_header >= start)
self.assertEqual(response.headers['x-put-timestamp'],
Timestamp(start).normal)
@ -209,7 +209,7 @@ class TestContainerController(unittest.TestCase):
self.assertEqual(int(response.headers
['X-Backend-Storage-Policy-Index']),
int(POLICIES.default))
self.assert_(
self.assertTrue(
Timestamp(response.headers['x-backend-timestamp']) >= start)
self.assertEqual(response.headers['x-backend-put-timestamp'],
Timestamp(start).internal)
@ -259,8 +259,8 @@ class TestContainerController(unittest.TestCase):
self.assertEqual(int(resp.headers[
'X-Backend-Storage-Policy-Index']),
int(POLICIES.default))
self.assert_(Timestamp(resp.headers['x-backend-timestamp']) >=
Timestamp(request_method_times['PUT']))
self.assertTrue(Timestamp(resp.headers['x-backend-timestamp']) >=
Timestamp(request_method_times['PUT']))
self.assertEqual(resp.headers['x-backend-put-timestamp'],
request_method_times['PUT'])
self.assertEqual(resp.headers['x-backend-delete-timestamp'],
@ -681,7 +681,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 204)
self.assert_('x-container-meta-test' not in resp.headers)
self.assertTrue('x-container-meta-test' not in resp.headers)
def test_PUT_GET_sys_metadata(self):
prefix = get_sys_meta_prefix('container')
@ -739,7 +739,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 204)
self.assert_(key.lower() not in resp.headers)
self.assertTrue(key.lower() not in resp.headers)
def test_PUT_invalid_partition(self):
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'PUT',
@ -816,7 +816,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 204)
self.assert_('x-container-meta-test' not in resp.headers)
self.assertTrue('x-container-meta-test' not in resp.headers)
def test_POST_HEAD_sys_metadata(self):
prefix = get_sys_meta_prefix('container')
@ -866,7 +866,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 204)
self.assert_(key.lower() not in resp.headers)
self.assertTrue(key.lower() not in resp.headers)
def test_POST_invalid_partition(self):
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'POST',
@ -1058,7 +1058,7 @@ class TestContainerController(unittest.TestCase):
err = event.wait()
if err:
raise Exception(err)
self.assert_(not got_exc)
self.assertTrue(not got_exc)
def test_PUT_reset_container_sync(self):
req = Request.blank(
@ -1580,7 +1580,7 @@ class TestContainerController(unittest.TestCase):
err = event.wait()
if err:
raise Exception(err)
self.assert_(not got_exc)
self.assertTrue(not got_exc)
def test_DELETE_invalid_partition(self):
req = Request.blank(
@ -2077,13 +2077,13 @@ class TestContainerController(unittest.TestCase):
environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller)
dom = minidom.parseString(resp.body)
self.assert_(len(dom.getElementsByTagName('container')) == 1)
self.assertTrue(len(dom.getElementsByTagName('container')) == 1)
container = dom.getElementsByTagName('container')[0]
self.assert_(len(container.getElementsByTagName('subdir')) == 1)
self.assertTrue(len(container.getElementsByTagName('subdir')) == 1)
subdir = container.getElementsByTagName('subdir')[0]
self.assertEquals(unicode(subdir.attributes['name'].value),
u'<\'sub\' "dir">/')
self.assert_(len(subdir.getElementsByTagName('name')) == 1)
self.assertTrue(len(subdir.getElementsByTagName('name')) == 1)
name = subdir.getElementsByTagName('name')[0]
self.assertEquals(unicode(name.childNodes[0].data),
u'<\'sub\' "dir">/')

View File

@ -66,13 +66,13 @@ class TestContainerUpdater(unittest.TestCase):
'concurrency': '2',
'node_timeout': '5',
})
self.assert_(hasattr(cu, 'logger'))
self.assert_(cu.logger is not None)
self.assertTrue(hasattr(cu, 'logger'))
self.assertTrue(cu.logger is not None)
self.assertEquals(cu.devices, self.devices_dir)
self.assertEquals(cu.interval, 1)
self.assertEquals(cu.concurrency, 2)
self.assertEquals(cu.node_timeout, 5)
self.assert_(cu.get_account_ring() is not None)
self.assertTrue(cu.get_account_ring() is not None)
def test_run_once(self):
cu = container_updater.ContainerUpdater({
@ -88,7 +88,7 @@ class TestContainerUpdater(unittest.TestCase):
containers_dir = os.path.join(self.sda1, DATADIR)
os.mkdir(containers_dir)
cu.run_once()
self.assert_(os.path.exists(containers_dir))
self.assertTrue(os.path.exists(containers_dir))
subdir = os.path.join(containers_dir, 'subdir')
os.mkdir(subdir)
cb = ContainerBroker(os.path.join(subdir, 'hash.db'), account='a',
@ -126,10 +126,10 @@ class TestContainerUpdater(unittest.TestCase):
headers[line.split(':')[0].lower()] = \
line.split(':')[1].strip()
line = inc.readline()
self.assert_('x-put-timestamp' in headers)
self.assert_('x-delete-timestamp' in headers)
self.assert_('x-object-count' in headers)
self.assert_('x-bytes-used' in headers)
self.assertTrue('x-put-timestamp' in headers)
self.assertTrue('x-delete-timestamp' in headers)
self.assertTrue('x-object-count' in headers)
self.assertTrue('x-bytes-used' in headers)
except BaseException as err:
import traceback
traceback.print_exc()

View File

@ -1959,7 +1959,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
# non-fast-post updateable keys are preserved
self.assertEquals('text/garbage', df._metadata['Content-Type'])
# original fast-post updateable keys are removed
self.assert_('X-Object-Meta-Key1' not in df._metadata)
self.assertTrue('X-Object-Meta-Key1' not in df._metadata)
# new fast-post updateable keys are added
self.assertEquals('Value2', df._metadata['X-Object-Meta-Key2'])
@ -2131,7 +2131,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
os.rmdir(tmpdir)
df = self._simple_get_diskfile(policy=policy)
with df.create():
self.assert_(os.path.exists(tmpdir))
self.assertTrue(os.path.exists(tmpdir))
def _get_open_disk_file(self, invalid_type=None, obj_name='o', fsize=1024,
csize=8, mark_deleted=False, prealloc=False,
@ -2965,7 +2965,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
pass
reader.close()
log_lines = df._logger.get_lines_for_level('error')
self.assert_('a very special error' in log_lines[-1])
self.assertTrue('a very special error' in log_lines[-1])
def test_diskfile_names(self):
df = self._simple_get_diskfile()
@ -3097,7 +3097,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
self.assertFalse(reader.can_zero_copy_send())
log_lines = df_mgr.logger.get_lines_for_level('warning')
self.assert_('MD5 sockets' in log_lines[-1])
self.assertTrue('MD5 sockets' in log_lines[-1])
def test_tee_to_md5_pipe_length_mismatch(self):
if not self._system_can_zero_copy():

View File

@ -176,27 +176,27 @@ class TestObjectController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c/o')
resp = req.get_response(self.object_controller)
self.assert_("X-Object-Meta-1" not in resp.headers and
"X-Object-Meta-Two" not in resp.headers and
"X-Object-Meta-3" in resp.headers and
"X-Object-Meta-4" in resp.headers and
"Foo" in resp.headers and
"Bar" in resp.headers and
"Baz" not in resp.headers and
"Content-Encoding" in resp.headers)
self.assertTrue("X-Object-Meta-1" not in resp.headers and
"X-Object-Meta-Two" not in resp.headers and
"X-Object-Meta-3" in resp.headers and
"X-Object-Meta-4" in resp.headers and
"Foo" in resp.headers and
"Bar" in resp.headers and
"Baz" not in resp.headers and
"Content-Encoding" in resp.headers)
self.assertEquals(resp.headers['Content-Type'], 'application/x-test')
req = Request.blank('/sda1/p/a/c/o',
environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.object_controller)
self.assert_("X-Object-Meta-1" not in resp.headers and
"X-Object-Meta-Two" not in resp.headers and
"X-Object-Meta-3" in resp.headers and
"X-Object-Meta-4" in resp.headers and
"Foo" in resp.headers and
"Bar" in resp.headers and
"Baz" not in resp.headers and
"Content-Encoding" in resp.headers)
self.assertTrue("X-Object-Meta-1" not in resp.headers and
"X-Object-Meta-Two" not in resp.headers and
"X-Object-Meta-3" in resp.headers and
"X-Object-Meta-4" in resp.headers and
"Foo" in resp.headers and
"Bar" in resp.headers and
"Baz" not in resp.headers and
"Content-Encoding" in resp.headers)
self.assertEquals(resp.headers['Content-Type'], 'application/x-test')
timestamp = normalize_timestamp(time())
@ -208,11 +208,11 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.status_int, 202)
req = Request.blank('/sda1/p/a/c/o')
resp = req.get_response(self.object_controller)
self.assert_("X-Object-Meta-3" not in resp.headers and
"X-Object-Meta-4" not in resp.headers and
"Foo" not in resp.headers and
"Bar" not in resp.headers and
"Content-Encoding" not in resp.headers)
self.assertTrue("X-Object-Meta-3" not in resp.headers and
"X-Object-Meta-4" not in resp.headers and
"Foo" not in resp.headers and
"Bar" not in resp.headers and
"Content-Encoding" not in resp.headers)
self.assertEquals(resp.headers['Content-Type'], 'application/x-test')
# test defaults
@ -232,11 +232,11 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.status_int, 201)
req = Request.blank('/sda1/p/a/c/o')
resp = req.get_response(self.object_controller)
self.assert_("X-Object-Meta-1" in resp.headers and
"Foo" not in resp.headers and
"Content-Encoding" in resp.headers and
"X-Object-Manifest" in resp.headers and
"Content-Disposition" in resp.headers)
self.assertTrue("X-Object-Meta-1" in resp.headers and
"Foo" not in resp.headers and
"Content-Encoding" in resp.headers and
"X-Object-Manifest" in resp.headers and
"Content-Disposition" in resp.headers)
self.assertEquals(resp.headers['Content-Type'], 'application/x-test')
timestamp = normalize_timestamp(time())
@ -250,12 +250,12 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.status_int, 202)
req = Request.blank('/sda1/p/a/c/o')
resp = req.get_response(self.object_controller)
self.assert_("X-Object-Meta-1" not in resp.headers and
"Foo" not in resp.headers and
"Content-Encoding" not in resp.headers and
"X-Object-Manifest" not in resp.headers and
"Content-Disposition" not in resp.headers and
"X-Object-Meta-3" in resp.headers)
self.assertTrue("X-Object-Meta-1" not in resp.headers and
"Foo" not in resp.headers and
"Content-Encoding" not in resp.headers and
"X-Object-Manifest" not in resp.headers and
"Content-Disposition" not in resp.headers and
"X-Object-Meta-3" in resp.headers)
self.assertEquals(resp.headers['Content-Type'], 'application/x-test')
# Test for empty metadata
@ -482,7 +482,7 @@ class TestObjectController(unittest.TestCase):
req.body = 'VERIFY'
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 400)
self.assert_('Content-Type' in resp.body)
self.assertTrue('Content-Type' in resp.body)
def test_PUT_no_content_length(self):
req = Request.blank(
@ -585,7 +585,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]),
'p', hash_path('a', 'c', 'o')),
utils.Timestamp(timestamp).internal + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(open(objfile).read(), 'VERIFY')
self.assertEquals(diskfile.read_metadata(objfile),
{'X-Timestamp': utils.Timestamp(timestamp).internal,
@ -620,7 +620,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
utils.Timestamp(timestamp).internal + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(open(objfile).read(), 'VERIFY TWO')
self.assertEquals(diskfile.read_metadata(objfile),
{'X-Timestamp': utils.Timestamp(timestamp).internal,
@ -732,7 +732,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
utils.Timestamp(timestamp).internal + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(open(objfile).read(), 'VERIFY THREE')
self.assertEquals(diskfile.read_metadata(objfile),
{'X-Timestamp': utils.Timestamp(timestamp).internal,
@ -1040,7 +1040,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
timestamp + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(open(objfile).read(), 'VERIFY SYSMETA')
self.assertEquals(diskfile.read_metadata(objfile),
{'X-Timestamp': timestamp,
@ -1083,7 +1083,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
timestamp1 + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(open(objfile).read(), 'VERIFY SYSMETA')
self.assertEquals(diskfile.read_metadata(objfile),
{'X-Timestamp': timestamp1,
@ -1101,7 +1101,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
timestamp2 + '.meta')
self.assert_(os.path.isfile(metafile))
self.assertTrue(os.path.isfile(metafile))
self.assertEquals(diskfile.read_metadata(metafile),
{'X-Timestamp': timestamp2,
'name': '/a/c/o',
@ -2346,7 +2346,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
utils.Timestamp(timestamp).internal + '.ts')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(1, calls_made[0])
self.assertEquals(len(os.listdir(os.path.dirname(objfile))), 1)
@ -2365,7 +2365,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
utils.Timestamp(timestamp).internal + '.ts')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
self.assertEquals(2, calls_made[0])
self.assertEquals(len(os.listdir(os.path.dirname(objfile))), 1)
@ -4190,7 +4190,7 @@ class TestObjectController(unittest.TestCase):
storage_directory(diskfile.get_data_dir(POLICIES[0]), 'p',
hash_path('a', 'c', 'o')),
utils.Timestamp(test_timestamp).internal + '.data')
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
# move time past expirery
with mock.patch('swift.obj.diskfile.time') as mock_time:
@ -4202,7 +4202,7 @@ class TestObjectController(unittest.TestCase):
# request will 404
self.assertEquals(resp.status_int, 404)
# but file still exists
self.assert_(os.path.isfile(objfile))
self.assertTrue(os.path.isfile(objfile))
# make the x-if-delete-at with some wrong bits
req = Request.blank(

View File

@ -1077,7 +1077,7 @@ class TestSender(BaseTestSender):
args, _kwargs = self.sender.send_put.call_args
path, df = args
self.assertEqual(path, '/a/c/o')
self.assert_(isinstance(df, diskfile.DiskFile))
self.assertTrue(isinstance(df, diskfile.DiskFile))
self.assertEqual(expected, df.get_metadata())
# note that the put line isn't actually sent since we mock send_put;
# send_put is tested separately.
@ -1112,7 +1112,7 @@ class TestSender(BaseTestSender):
args, _kwargs = self.sender.send_put.call_args
path, df = args
self.assertEqual(path, '/a/c/o')
self.assert_(isinstance(df, diskfile.DiskFile))
self.assertTrue(isinstance(df, diskfile.DiskFile))
self.assertEqual(expected, df.get_metadata())
self.assertEqual(os.path.join(self.testdir, 'dev/objects/9/',
object_hash[-3:], object_hash),

View File

@ -85,13 +85,13 @@ class TestObjectUpdater(unittest.TestCase):
'interval': '1',
'concurrency': '2',
'node_timeout': '5'})
self.assert_(hasattr(cu, 'logger'))
self.assert_(cu.logger is not None)
self.assertTrue(hasattr(cu, 'logger'))
self.assertTrue(cu.logger is not None)
self.assertEquals(cu.devices, self.devices_dir)
self.assertEquals(cu.interval, 1)
self.assertEquals(cu.concurrency, 2)
self.assertEquals(cu.node_timeout, 5)
self.assert_(cu.get_container_ring() is not None)
self.assertTrue(cu.get_container_ring() is not None)
@mock.patch('os.listdir')
def test_listdir_with_exception(self, mock_listdir):
@ -184,14 +184,15 @@ class TestObjectUpdater(unittest.TestCase):
cu.logger = mock_logger = mock.MagicMock()
cu.object_sweep(self.sda1)
self.assertEquals(mock_logger.warn.call_count, warn)
self.assert_(os.path.exists(os.path.join(self.sda1, 'not_a_dir')))
self.assertTrue(
os.path.exists(os.path.join(self.sda1, 'not_a_dir')))
if should_skip:
# if we were supposed to skip over the dir, we didn't process
# anything at all
self.assertTrue(os.path.exists(prefix_dir))
self.assertEqual(set(), seen)
else:
self.assert_(not os.path.exists(prefix_dir))
self.assertTrue(not os.path.exists(prefix_dir))
self.assertEqual(expected, seen)
# test cleanup: the tempdir gets cleaned up between runs, but this
@ -220,7 +221,7 @@ class TestObjectUpdater(unittest.TestCase):
async_dir = os.path.join(self.sda1, get_async_dir(POLICIES[0]))
os.mkdir(async_dir)
cu.run_once()
self.assert_(os.path.exists(async_dir))
self.assertTrue(os.path.exists(async_dir))
# mount_check == False means no call to ismount
self.assertEqual([], mock_ismount.mock_calls)
@ -235,8 +236,8 @@ class TestObjectUpdater(unittest.TestCase):
'to be here')
os.mkdir(odd_dir)
cu.run_once()
self.assert_(os.path.exists(async_dir))
self.assert_(os.path.exists(odd_dir)) # skipped - not mounted!
self.assertTrue(os.path.exists(async_dir))
self.assertTrue(os.path.exists(odd_dir)) # skipped - not mounted!
# mount_check == True means ismount was checked
self.assertEqual([
mock.call(self.sda1),
@ -257,7 +258,7 @@ class TestObjectUpdater(unittest.TestCase):
async_dir = os.path.join(self.sda1, get_async_dir(POLICIES[0]))
os.mkdir(async_dir)
cu.run_once()
self.assert_(os.path.exists(async_dir))
self.assertTrue(os.path.exists(async_dir))
# mount_check == False means no call to ismount
self.assertEqual([], mock_ismount.mock_calls)
@ -272,8 +273,8 @@ class TestObjectUpdater(unittest.TestCase):
'to be here')
os.mkdir(odd_dir)
cu.run_once()
self.assert_(os.path.exists(async_dir))
self.assert_(not os.path.exists(odd_dir))
self.assertTrue(os.path.exists(async_dir))
self.assertTrue(not os.path.exists(odd_dir))
# mount_check == True means ismount was checked
self.assertEqual([
mock.call(self.sda1),
@ -297,8 +298,8 @@ class TestObjectUpdater(unittest.TestCase):
normalize_timestamp(0)}},
async_pending)
cu.run_once()
self.assert_(not os.path.exists(older_op_path))
self.assert_(os.path.exists(op_path))
self.assertTrue(not os.path.exists(older_op_path))
self.assertTrue(os.path.exists(op_path))
self.assertEqual(cu.logger.get_increment_counts(),
{'failures': 1, 'unlinks': 1})
self.assertEqual(None,
@ -356,7 +357,7 @@ class TestObjectUpdater(unittest.TestCase):
err = event.wait()
if err:
raise err
self.assert_(os.path.exists(op_path))
self.assertTrue(os.path.exists(op_path))
self.assertEqual(cu.logger.get_increment_counts(),
{'failures': 1})
self.assertEqual([0],
@ -368,7 +369,7 @@ class TestObjectUpdater(unittest.TestCase):
err = event.wait()
if err:
raise err
self.assert_(os.path.exists(op_path))
self.assertTrue(os.path.exists(op_path))
self.assertEqual(cu.logger.get_increment_counts(),
{'failures': 1})
self.assertEqual([0, 1],
@ -380,7 +381,7 @@ class TestObjectUpdater(unittest.TestCase):
err = event.wait()
if err:
raise err
self.assert_(not os.path.exists(op_path))
self.assertTrue(not os.path.exists(op_path))
self.assertEqual(cu.logger.get_increment_counts(),
{'unlinks': 1, 'successes': 1})

View File

@ -193,7 +193,7 @@ class TestAccountController(unittest.TestCase):
self.assertEqual(resp.headers.get(header), value)
else:
# blank ACLs should result in no header
self.assert_(header not in resp.headers)
self.assertTrue(header not in resp.headers)
def test_add_acls_impossible_cases(self):
# For test coverage: verify that defensive coding does defend, in cases

View File

@ -169,7 +169,7 @@ class TestContainerController(TestRingBase):
self.assertEqual(resp.status_int, expected)
for req in fake_conn.requests:
self.assertEqual(req['method'], method)
self.assert_(req['path'].endswith('/a/c'))
self.assertTrue(req['path'].endswith('/a/c'))
base_status = [201] * 3
# test happy path

View File

@ -750,7 +750,7 @@ class TestProxyServer(unittest.TestCase):
req.environ['swift.authorize'] = authorize
app.update_request(req)
app.handle_request(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_calls_authorize_deny(self):
called = [False]
@ -765,7 +765,7 @@ class TestProxyServer(unittest.TestCase):
req.environ['swift.authorize'] = authorize
app.update_request(req)
app.handle_request(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_negative_content_length(self):
swift_dir = mkdtemp()
@ -1118,7 +1118,7 @@ class TestProxyServerLoading(unittest.TestCase):
# all rings exist, app should load
loadapp(conf_path)
for policy in POLICIES:
self.assert_(policy.object_ring)
self.assertTrue(policy.object_ring)
@patch_policies([StoragePolicy(0, 'zero', True,
@ -1350,7 +1350,7 @@ class TestObjectController(unittest.TestCase):
try:
df.open()
except DiskFileNotExist as e:
self.assert_(float(e.timestamp) > 0)
self.assertTrue(float(e.timestamp) > 0)
else:
self.fail('did not raise DiskFileNotExist')
@ -3232,9 +3232,9 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(res.status[:len(str(expected))],
str(expected))
if expected < 400:
self.assert_('x-works' in res.headers)
self.assertTrue('x-works' in res.headers)
self.assertEquals(res.headers['x-works'], 'yes')
self.assert_('accept-ranges' in res.headers)
self.assertTrue('accept-ranges' in res.headers)
self.assertEquals(res.headers['accept-ranges'], 'bytes')
test_status_map((200, 200, 200, 404, 404), 200)
@ -3594,7 +3594,7 @@ class TestObjectController(unittest.TestCase):
resp.body
except ChunkReadTimeout:
got_exc = True
self.assert_(not got_exc)
self.assertTrue(not got_exc)
self.app.recoverable_node_timeout = 0.1
set_http_connect(200, 200, 200, slow=1.0)
resp = req.get_response(self.app)
@ -3603,7 +3603,7 @@ class TestObjectController(unittest.TestCase):
resp.body
except ChunkReadTimeout:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
def test_node_read_timeout_retry(self):
with save_globals():
@ -3631,7 +3631,7 @@ class TestObjectController(unittest.TestCase):
self.assertEquals('', resp.body)
except ChunkReadTimeout:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
set_http_connect(200, 200, 200, body='lalala',
slow=[1.0, 1.0])
@ -3641,7 +3641,7 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.body, 'lalala')
except ChunkReadTimeout:
got_exc = True
self.assert_(not got_exc)
self.assertTrue(not got_exc)
set_http_connect(200, 200, 200, body='lalala',
slow=[1.0, 1.0], etags=['a', 'a', 'a'])
@ -3651,7 +3651,7 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.body, 'lalala')
except ChunkReadTimeout:
got_exc = True
self.assert_(not got_exc)
self.assertTrue(not got_exc)
set_http_connect(200, 200, 200, body='lalala',
slow=[1.0, 1.0], etags=['a', 'b', 'a'])
@ -3661,7 +3661,7 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.body, 'lalala')
except ChunkReadTimeout:
got_exc = True
self.assert_(not got_exc)
self.assertTrue(not got_exc)
req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'})
set_http_connect(200, 200, 200, body='lalala',
@ -3672,7 +3672,7 @@ class TestObjectController(unittest.TestCase):
resp.body
except ChunkReadTimeout:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
def test_node_write_timeout(self):
with save_globals():
@ -3944,8 +3944,9 @@ class TestObjectController(unittest.TestCase):
200)
self.assertEquals(
node_error_count(controller.app, object_ring.devs[0]), 2)
self.assert_(node_last_error(controller.app, object_ring.devs[0])
is not None)
self.assertTrue(
node_last_error(controller.app, object_ring.devs[0])
is not None)
for _junk in range(self.app.error_suppression_limit):
self.assert_status_map(controller.HEAD, (200, 200, 503, 503,
503), 503)
@ -3954,8 +3955,9 @@ class TestObjectController(unittest.TestCase):
self.app.error_suppression_limit + 1)
self.assert_status_map(controller.HEAD, (200, 200, 200, 200, 200),
503)
self.assert_(node_last_error(controller.app, object_ring.devs[0])
is not None)
self.assertTrue(
node_last_error(controller.app, object_ring.devs[0])
is not None)
self.assert_status_map(controller.PUT, (200, 200, 200, 201, 201,
201), 503)
self.assert_status_map(controller.POST,
@ -3981,8 +3983,9 @@ class TestObjectController(unittest.TestCase):
200)
self.assertEquals(
node_error_count(controller.app, object_ring.devs[0]), 2)
self.assert_(node_last_error(controller.app, object_ring.devs[0])
is not None)
self.assertTrue(
node_last_error(controller.app, object_ring.devs[0])
is not None)
for _junk in range(self.app.error_suppression_limit):
self.assert_status_map(controller.HEAD, (200, 200, 503, 503,
503), 503)
@ -4014,9 +4017,10 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(node_error_count(controller.app, odevs[0]), 2)
self.assertEquals(node_error_count(controller.app, odevs[1]), 0)
self.assertEquals(node_error_count(controller.app, odevs[2]), 0)
self.assert_(node_last_error(controller.app, odevs[0]) is not None)
self.assert_(node_last_error(controller.app, odevs[1]) is None)
self.assert_(node_last_error(controller.app, odevs[2]) is None)
self.assertTrue(
node_last_error(controller.app, odevs[0]) is not None)
self.assertTrue(node_last_error(controller.app, odevs[1]) is None)
self.assertTrue(node_last_error(controller.app, odevs[2]) is None)
def test_PUT_error_limiting_last_node(self):
with save_globals():
@ -4033,9 +4037,10 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(node_error_count(controller.app, odevs[0]), 0)
self.assertEquals(node_error_count(controller.app, odevs[1]), 0)
self.assertEquals(node_error_count(controller.app, odevs[2]), 2)
self.assert_(node_last_error(controller.app, odevs[0]) is None)
self.assert_(node_last_error(controller.app, odevs[1]) is None)
self.assert_(node_last_error(controller.app, odevs[2]) is not None)
self.assertTrue(node_last_error(controller.app, odevs[0]) is None)
self.assertTrue(node_last_error(controller.app, odevs[1]) is None)
self.assertTrue(
node_last_error(controller.app, odevs[2]) is not None)
def test_acc_or_con_missing_returns_404(self):
with save_globals():
@ -5153,7 +5158,7 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 204'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('\r\nContent-Length: 0\r\n' in headers)
self.assertTrue('\r\nContent-Length: 0\r\n' in headers)
@unpatch_policies
def test_chunked_put_utf8_all_the_way_down(self):
@ -5188,7 +5193,7 @@ class TestObjectController(unittest.TestCase):
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
containers = fd.read().split('\n')
self.assert_(ustr in containers)
self.assertTrue(ustr in containers)
# List account with ustr container (test json)
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5200,7 +5205,7 @@ class TestObjectController(unittest.TestCase):
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
listing = json.loads(fd.read())
self.assert_(ustr.decode('utf8') in [l['name'] for l in listing])
self.assertTrue(ustr.decode('utf8') in [l['name'] for l in listing])
# List account with ustr container (test xml)
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5211,7 +5216,7 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('<name>%s</name>' % ustr in fd.read())
self.assertTrue('<name>%s</name>' % ustr in fd.read())
# Create ustr object with ustr metadata in ustr container
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5235,7 +5240,7 @@ class TestObjectController(unittest.TestCase):
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
objects = fd.read().split('\n')
self.assert_(ustr in objects)
self.assertTrue(ustr in objects)
# List ustr container with ustr object (test json)
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5260,7 +5265,7 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('<name>%s</name>' % ustr in fd.read())
self.assertTrue('<name>%s</name>' % ustr in fd.read())
# Retrieve ustr object with ustr metadata
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5272,8 +5277,8 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('\r\nX-Object-Meta-%s: %s\r\n' %
(quote(ustr_short).lower(), quote(ustr)) in headers)
self.assertTrue('\r\nX-Object-Meta-%s: %s\r\n' %
(quote(ustr_short).lower(), quote(ustr)) in headers)
@unpatch_policies
def test_chunked_put_chunked_put(self):
@ -5337,7 +5342,7 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 2' # 2xx series response
self.assertEquals(headers[:len(exp)], exp)
self.assert_('X-Versions-Location: %s' % vc in headers)
self.assertTrue('X-Versions-Location: %s' % vc in headers)
# make the container for the object versions
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
fd = sock.makefile()
@ -5382,8 +5387,9 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('Content-Type: text/jibberish%s' % segment in headers)
self.assert_('X-Object-Meta-Foo: barbaz' not in headers)
self.assertTrue(
'Content-Type: text/jibberish%s' % segment in headers)
self.assertTrue('X-Object-Meta-Foo: barbaz' not in headers)
body = fd.read()
self.assertEquals(body, '%05d' % segment)
# Ensure we have the right number of versions saved
@ -5441,8 +5447,8 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('Content-Type: foo/bar' in headers)
self.assert_('X-Object-Meta-Bar: foo' in headers)
self.assertTrue('Content-Type: foo/bar' in headers)
self.assertTrue('X-Object-Meta-Bar: foo' in headers)
body = fd.read()
self.assertEquals(body, '%05d' % segment)
# Delete the object versions
@ -5466,8 +5472,8 @@ class TestObjectController(unittest.TestCase):
headers = readuntil2crlfs(fd)
exp = 'HTTP/1.1 200'
self.assertEquals(headers[:len(exp)], exp)
self.assert_('Content-Type: text/jibberish%s' % (segment - 1)
in headers)
self.assertTrue('Content-Type: text/jibberish%s' % (segment - 1)
in headers)
body = fd.read()
self.assertEquals(body, '%05d' % (segment - 1))
# Ensure we have the right number of versions saved
@ -5779,7 +5785,7 @@ class TestObjectController(unittest.TestCase):
self.app, 'account', 'container', 'object')
set_http_connect(200, 200, 200)
resp = controller.GET(req)
self.assert_('accept-ranges' in resp.headers)
self.assertTrue('accept-ranges' in resp.headers)
self.assertEquals(resp.headers['accept-ranges'], 'bytes')
def test_response_head_accept_ranges_header(self):
@ -5791,7 +5797,7 @@ class TestObjectController(unittest.TestCase):
self.app, 'account', 'container', 'object')
set_http_connect(200, 200, 200)
resp = controller.HEAD(req)
self.assert_('accept-ranges' in resp.headers)
self.assertTrue('accept-ranges' in resp.headers)
self.assertEquals(resp.headers['accept-ranges'], 'bytes')
def test_GET_calls_authorize(self):
@ -5808,7 +5814,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.GET(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_HEAD_calls_authorize(self):
called = [False]
@ -5824,7 +5830,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.HEAD(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_POST_calls_authorize(self):
called = [False]
@ -5843,7 +5849,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.POST(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_POST_as_copy_calls_authorize(self):
called = [False]
@ -5861,7 +5867,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.POST(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_PUT_calls_authorize(self):
called = [False]
@ -5878,7 +5884,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.PUT(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_COPY_calls_authorize(self):
called = [False]
@ -5896,7 +5902,7 @@ class TestObjectController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.COPY(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_POST_converts_delete_after_to_delete_at(self):
with save_globals():
@ -7209,7 +7215,7 @@ class TestContainerController(unittest.TestCase):
self.assertEquals(res.status[:len(str(expected))],
str(expected))
if expected < 400:
self.assert_('x-works' in res.headers)
self.assertTrue('x-works' in res.headers)
self.assertEquals(res.headers['x-works'], 'yes')
if c_expected:
self.assertTrue('swift.container/a/c' in res.environ)
@ -7233,7 +7239,7 @@ class TestContainerController(unittest.TestCase):
self.assertEquals(res.status[:len(str(expected))],
str(expected))
if expected < 400:
self.assert_('x-works' in res.headers)
self.assertTrue('x-works' in res.headers)
self.assertEquals(res.headers['x-works'], 'yes')
if c_expected:
self.assertTrue('swift.container/a/c' in res.environ)
@ -7591,7 +7597,7 @@ class TestContainerController(unittest.TestCase):
self.assertEquals(
node_error_count(controller.app, container_ring.devs[0]), 2)
self.assert_(
self.assertTrue(
node_last_error(controller.app, container_ring.devs[0])
is not None)
for _junk in range(self.app.error_suppression_limit):
@ -7601,7 +7607,7 @@ class TestContainerController(unittest.TestCase):
node_error_count(controller.app, container_ring.devs[0]),
self.app.error_suppression_limit + 1)
self.assert_status_map(controller.HEAD, (200, 200, 200, 200), 503)
self.assert_(
self.assertTrue(
node_last_error(controller.app, container_ring.devs[0])
is not None)
self.assert_status_map(controller.PUT, (200, 201, 201, 201), 503,
@ -7643,7 +7649,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/v1/a/c?format=json')
self.app.update_request(req)
res = controller.GET(req)
self.assert_('accept-ranges' in res.headers)
self.assertTrue('accept-ranges' in res.headers)
self.assertEqual(res.headers['accept-ranges'], 'bytes')
def test_response_head_accept_ranges_header(self):
@ -7654,7 +7660,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/v1/a/c?format=json')
self.app.update_request(req)
res = controller.HEAD(req)
self.assert_('accept-ranges' in res.headers)
self.assertTrue('accept-ranges' in res.headers)
self.assertEqual(res.headers['accept-ranges'], 'bytes')
def test_PUT_metadata(self):
@ -7809,7 +7815,7 @@ class TestContainerController(unittest.TestCase):
req.environ['swift.clean_acl'] = clean_acl
self.app.update_request(req)
controller.POST(req)
self.assert_(called[0])
self.assertTrue(called[0])
called[0] = False
with save_globals():
set_http_connect(200, 201, 201, 201)
@ -7820,7 +7826,7 @@ class TestContainerController(unittest.TestCase):
req.environ['swift.clean_acl'] = clean_acl
self.app.update_request(req)
controller.POST(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_PUT_calls_clean_acl(self):
called = [False]
@ -7837,7 +7843,7 @@ class TestContainerController(unittest.TestCase):
req.environ['swift.clean_acl'] = clean_acl
self.app.update_request(req)
controller.PUT(req)
self.assert_(called[0])
self.assertTrue(called[0])
called[0] = False
with save_globals():
set_http_connect(200, 201, 201, 201)
@ -7848,7 +7854,7 @@ class TestContainerController(unittest.TestCase):
req.environ['swift.clean_acl'] = clean_acl
self.app.update_request(req)
controller.PUT(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_GET_no_content(self):
with save_globals():
@ -7879,7 +7885,7 @@ class TestContainerController(unittest.TestCase):
self.app.update_request(req)
res = controller.GET(req)
self.assertEquals(res.environ['swift.container/a/c']['status'], 201)
self.assert_(called[0])
self.assertTrue(called[0])
def test_HEAD_calls_authorize(self):
called = [False]
@ -7895,7 +7901,7 @@ class TestContainerController(unittest.TestCase):
req.environ['swift.authorize'] = authorize
self.app.update_request(req)
controller.HEAD(req)
self.assert_(called[0])
self.assertTrue(called[0])
def test_unauthorized_requests_when_account_not_found(self):
# verify unauthorized container requests always return response
@ -8288,7 +8294,7 @@ class TestContainerController(unittest.TestCase):
self.assertEqual(3, len(timestamps))
for timestamp in timestamps:
self.assertEqual(timestamp, timestamps[0])
self.assert_(re.match('[0-9]{10}\.[0-9]{5}', timestamp))
self.assertTrue(re.match('[0-9]{10}\.[0-9]{5}', timestamp))
def test_DELETE_backed_x_timestamp_header(self):
timestamps = []
@ -8313,7 +8319,7 @@ class TestContainerController(unittest.TestCase):
self.assertEqual(3, len(timestamps))
for timestamp in timestamps:
self.assertEqual(timestamp, timestamps[0])
self.assert_(re.match('[0-9]{10}\.[0-9]{5}', timestamp))
self.assertTrue(re.match('[0-9]{10}\.[0-9]{5}', timestamp))
def test_node_read_timeout_retry_to_container(self):
with save_globals():
@ -8326,7 +8332,7 @@ class TestContainerController(unittest.TestCase):
resp.body
except ChunkReadTimeout:
got_exc = True
self.assert_(got_exc)
self.assertTrue(got_exc)
@patch_policies([StoragePolicy(0, 'zero', True, object_ring=FakeRing())])
@ -8557,7 +8563,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/v1/a?format=json')
self.app.update_request(req)
res = controller.GET(req)
self.assert_('accept-ranges' in res.headers)
self.assertTrue('accept-ranges' in res.headers)
self.assertEqual(res.headers['accept-ranges'], 'bytes')
def test_response_head_accept_ranges_header(self):
@ -8568,7 +8574,7 @@ class TestAccountController(unittest.TestCase):
self.app.update_request(req)
res = controller.HEAD(req)
res.body
self.assert_('accept-ranges' in res.headers)
self.assertTrue('accept-ranges' in res.headers)
self.assertEqual(res.headers['accept-ranges'], 'bytes')
def test_PUT(self):
@ -8905,7 +8911,7 @@ class TestAccountControllerFakeGetResponse(unittest.TestCase):
# Not a swift_owner -- ACLs should NOT be in response
header = 'X-Account-Access-Control'
self.assert_(header not in resp.headers, '%r was in %r' % (
self.assertTrue(header not in resp.headers, '%r was in %r' % (
header, resp.headers))
# Same setup -- mock acct server will provide ACLs
@ -8915,7 +8921,7 @@ class TestAccountControllerFakeGetResponse(unittest.TestCase):
resp = app.handle_request(req)
# For a swift_owner, the ACLs *should* be in response
self.assert_(header in resp.headers, '%r not in %r' % (
self.assertTrue(header in resp.headers, '%r not in %r' % (
header, resp.headers))
def test_account_acls_through_delegation(self):