Replace 'assertTrue(a not in b)' with 'assertNotIn(a, b)'

trivialfix

Change-Id: I416831c8ad92f8445bc8d9560040a5ebf5c90702
This commit is contained in:
Cao Xuan Hoang 2016-12-12 15:18:52 +07:00
parent e67a57fb17
commit 3da144a3af
15 changed files with 104 additions and 104 deletions

View File

@ -77,7 +77,7 @@ class TestAccountController(unittest.TestCase):
'HTTP_X_TIMESTAMP': '0'}) 'HTTP_X_TIMESTAMP': '0'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('X-Account-Status' not in resp.headers) self.assertNotIn('X-Account-Status', resp.headers)
def test_DELETE_empty(self): def test_DELETE_empty(self):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
@ -243,7 +243,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('X-Account-Status' not in resp.headers) self.assertNotIn('X-Account-Status', resp.headers)
# Test the case in which account was deleted but not yet reaped # Test the case in which account was deleted but not yet reaped
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
@ -356,7 +356,7 @@ class TestAccountController(unittest.TestCase):
'X-Timestamp': normalize_timestamp(0)}) 'X-Timestamp': normalize_timestamp(0)})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('X-Account-Status' not in resp.headers) self.assertNotIn('X-Account-Status', resp.headers)
def test_PUT(self): def test_PUT(self):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
@ -501,7 +501,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue('x-account-meta-test' not in resp.headers) self.assertNotIn('x-account-meta-test', resp.headers)
def test_PUT_GET_sys_metadata(self): def test_PUT_GET_sys_metadata(self):
prefix = get_sys_meta_prefix('account') prefix = get_sys_meta_prefix('account')
@ -562,7 +562,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue(hdr not in resp.headers) self.assertNotIn(hdr, resp.headers)
def test_PUT_invalid_partition(self): def test_PUT_invalid_partition(self):
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'PUT',
@ -626,7 +626,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue('x-account-meta-test' not in resp.headers) self.assertNotIn('x-account-meta-test', resp.headers)
def test_POST_HEAD_sys_metadata(self): def test_POST_HEAD_sys_metadata(self):
prefix = get_sys_meta_prefix('account') prefix = get_sys_meta_prefix('account')
@ -679,7 +679,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue(hdr not in resp.headers) self.assertNotIn(hdr, resp.headers)
def test_POST_invalid_partition(self): def test_POST_invalid_partition(self):
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'POST', req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'POST',
@ -721,7 +721,7 @@ class TestAccountController(unittest.TestCase):
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'}) req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('X-Account-Status' not in resp.headers) self.assertNotIn('X-Account-Status', resp.headers)
# Test the case in which account was deleted but not yet reaped # Test the case in which account was deleted but not yet reaped
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
@ -1963,7 +1963,7 @@ class TestAccountController(unittest.TestCase):
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int // 100, 2) self.assertEqual(resp.status_int // 100, 2)
for key in resp.headers: for key in resp.headers:
self.assertTrue('storage-policy' not in key.lower()) self.assertNotIn('storage-policy', key.lower())
def test_empty_except_for_used_policies(self): def test_empty_except_for_used_policies(self):
ts = itertools.count() ts = itertools.count()
@ -1979,7 +1979,7 @@ class TestAccountController(unittest.TestCase):
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int // 100, 2) self.assertEqual(resp.status_int // 100, 2)
for key in resp.headers: for key in resp.headers:
self.assertTrue('storage-policy' not in key.lower()) self.assertNotIn('storage-policy', key.lower())
# add a container # add a container
policy = random.choice(POLICIES) policy = random.choice(POLICIES)

View File

@ -242,7 +242,7 @@ class TestFormPost(unittest.TestCase):
'/v1/a/c/o', '/v1/a/c/o',
environ={'REQUEST_METHOD': method}).get_response(self.formpost) environ={'REQUEST_METHOD': method}).get_response(self.formpost)
self.assertEqual(resp.status_int, 401) self.assertEqual(resp.status_int, 401)
self.assertTrue('FormPost' not in resp.body) self.assertNotIn('FormPost', resp.body)
def test_auth_scheme(self): def test_auth_scheme(self):
# FormPost rejects # FormPost rejects

View File

@ -92,8 +92,8 @@ class TestGatekeeper(unittest.TestCase):
def _assertHeadersAbsent(self, unexpected, actual): def _assertHeadersAbsent(self, unexpected, actual):
for key in unexpected: for key in unexpected:
self.assertTrue(key.lower() not in actual, self.assertNotIn(key.lower(), actual,
'%s is in %s' % (key, actual)) '%s is in %s' % (key, actual))
def get_app(self, app, global_conf, **local_conf): def get_app(self, app, global_conf, **local_conf):
factory = gatekeeper.filter_factory(global_conf, **local_conf) factory = gatekeeper.filter_factory(global_conf, **local_conf)

View File

@ -455,8 +455,8 @@ class TestProxyLogging(unittest.TestCase):
headers = unquote(log_parts[14]).split('\n') headers = unquote(log_parts[14]).split('\n')
self.assertTrue('First: 1' in headers) self.assertTrue('First: 1' in headers)
self.assertTrue('Second: 2' in headers) self.assertTrue('Second: 2' in headers)
self.assertTrue('Third: 3' not in headers) self.assertNotIn('Third: 3', headers)
self.assertTrue('Host: localhost:80' not in headers) self.assertNotIn('Host: localhost:80', headers)
def test_upload_size(self): def test_upload_size(self):
# Using default policy # Using default policy

View File

@ -468,7 +468,7 @@ class TestSloPutManifest(SloTestCase):
'/v1/AUTH_test/c/man?multipart-manifest=put', '/v1/AUTH_test/c/man?multipart-manifest=put',
environ={'REQUEST_METHOD': 'PUT'}, headers={'Accept': 'test'}, environ={'REQUEST_METHOD': 'PUT'}, headers={'Accept': 'test'},
body=test_json_data) body=test_json_data)
self.assertTrue('X-Static-Large-Object' not in req.headers) self.assertNotIn('X-Static-Large-Object', req.headers)
self.slo(req.environ, fake_start_response) self.slo(req.environ, fake_start_response)
self.assertTrue('X-Static-Large-Object' in req.headers) self.assertTrue('X-Static-Large-Object' in req.headers)
self.assertTrue(req.environ['PATH_INFO'], '/cont/object\xe2\x99\xa1') self.assertTrue(req.environ['PATH_INFO'], '/cont/object\xe2\x99\xa1')
@ -1728,7 +1728,7 @@ class TestSloGetManifest(SloTestCase):
self.assertEqual(status, '206 Partial Content') self.assertEqual(status, '206 Partial Content')
self.assertEqual(headers['Content-Length'], '15') self.assertEqual(headers['Content-Length'], '15')
self.assertTrue('Etag' not in headers) self.assertNotIn('Etag', headers)
self.assertEqual(body, 'aabbbbbbbbbbccc') self.assertEqual(body, 'aabbbbbbbbbbccc')
self.assertEqual( self.assertEqual(
@ -1973,7 +1973,7 @@ class TestSloGetManifest(SloTestCase):
self.assertEqual(status, '206 Partial Content') self.assertEqual(status, '206 Partial Content')
self.assertEqual(headers['Content-Length'], '25') self.assertEqual(headers['Content-Length'], '25')
self.assertTrue('Etag' not in headers) self.assertNotIn('Etag', headers)
self.assertEqual(body, 'bbbbbbbbbbccccccccccccccc') self.assertEqual(body, 'bbbbbbbbbbccccccccccccccc')
self.assertEqual( self.assertEqual(

View File

@ -556,8 +556,8 @@ class TestStaticWeb(unittest.TestCase):
self.assertEqual(resp.status_int, 200) self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body) self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body)
self.assertTrue('</style>' in resp.body) self.assertTrue('</style>' in resp.body)
self.assertTrue('<link' not in resp.body) self.assertNotIn('<link', resp.body)
self.assertTrue('listing.css' not in resp.body) self.assertNotIn('listing.css', resp.body)
def test_container3subdirx(self): def test_container3subdirx(self):
resp = Request.blank( resp = Request.blank(
@ -578,7 +578,7 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank( resp = Request.blank(
'/v1/a/c3/unknown').get_response(self.test_staticweb) '/v1/a/c3/unknown').get_response(self.test_staticweb)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body) self.assertNotIn("Chrome's 404 fancy-page sucks.", resp.body)
def test_container3bindexhtml(self): def test_container3bindexhtml(self):
resp = Request.blank('/v1/a/c3b/').get_response(self.test_staticweb) resp = Request.blank('/v1/a/c3b/').get_response(self.test_staticweb)
@ -616,7 +616,7 @@ class TestStaticWeb(unittest.TestCase):
'/v1/a/c4/subdir/').get_response(self.test_staticweb) '/v1/a/c4/subdir/').get_response(self.test_staticweb)
self.assertEqual(resp.status_int, 200) self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c4/subdir/' in resp.body) self.assertTrue('Listing of /v1/a/c4/subdir/' in resp.body)
self.assertTrue('</style>' not in resp.body) self.assertNotIn('</style>', resp.body)
self.assertTrue('<link' in resp.body) self.assertTrue('<link' in resp.body)
self.assertTrue('href="../listing.css"' in resp.body) self.assertTrue('href="../listing.css"' in resp.body)
self.assertEqual(resp.headers['content-type'], self.assertEqual(resp.headers['content-type'],
@ -640,7 +640,7 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank( resp = Request.blank(
'/v1/a/c5/unknown').get_response(self.test_staticweb) '/v1/a/c5/unknown').get_response(self.test_staticweb)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body) self.assertNotIn("Chrome's 404 fancy-page sucks.", resp.body)
def test_container6subdir(self): def test_container6subdir(self):
resp = Request.blank( resp = Request.blank(
@ -796,7 +796,7 @@ class TestStaticWeb(unittest.TestCase):
resp = Request.blank('/v1/a/c7/').get_response( resp = Request.blank('/v1/a/c7/').get_response(
self.test_staticweb) self.test_staticweb)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('listing.css' not in resp.body) self.assertNotIn('listing.css', resp.body)
self.assertTrue('<style' in resp.body) self.assertTrue('<style' in resp.body)
def test_subrequest_once_if_possible(self): def test_subrequest_once_if_possible(self):

View File

@ -204,14 +204,14 @@ class TestAuth(unittest.TestCase):
environ={'swift.authorize_override': True}) environ={'swift.authorize_override': True})
resp = req.get_response(self.test_auth) resp = req.get_response(self.test_auth)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('swift.authorize' not in req.environ) self.assertNotIn('swift.authorize', req.environ)
def test_override_default_allowed(self): def test_override_default_allowed(self):
req = self._make_request('/v1/AUTH_account', req = self._make_request('/v1/AUTH_account',
environ={'swift.authorize_override': True}) environ={'swift.authorize_override': True})
resp = req.get_response(self.test_auth) resp = req.get_response(self.test_auth)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('swift.authorize' not in req.environ) self.assertNotIn('swift.authorize', req.environ)
def test_auth_deny_non_reseller_prefix(self): def test_auth_deny_non_reseller_prefix(self):
req = self._make_request('/v1/BLAH_account', req = self._make_request('/v1/BLAH_account',

View File

@ -116,7 +116,7 @@ class TestTempURL(unittest.TestCase):
def test_passthrough(self): def test_passthrough(self):
resp = self._make_request('/v1/a/c/o').get_response(self.tempurl) resp = self._make_request('/v1/a/c/o').get_response(self.tempurl)
self.assertEqual(resp.status_int, 401) self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' not in resp.body) self.assertNotIn('Temp URL invalid', resp.body)
def test_allow_options(self): def test_allow_options(self):
self.app.status_headers_body_iter = iter([('200 Ok', {}, '')]) self.app.status_headers_body_iter = iter([('200 Ok', {}, '')])
@ -821,7 +821,7 @@ class TestTempURL(unittest.TestCase):
sig, expires)}) sig, expires)})
resp = req.get_response(self.tempurl) resp = req.get_response(self.tempurl)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('x-remove-this' not in self.app.request.headers) self.assertNotIn('x-remove-this', self.app.request.headers)
def test_removed_incoming_headers_match(self): def test_removed_incoming_headers_match(self):
self.tempurl = tempurl.filter_factory({ self.tempurl = tempurl.filter_factory({
@ -841,7 +841,7 @@ class TestTempURL(unittest.TestCase):
sig, expires)}) sig, expires)})
resp = req.get_response(self.tempurl) resp = req.get_response(self.tempurl)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('x-remove-this-one' not in self.app.request.headers) self.assertNotIn('x-remove-this-one', self.app.request.headers)
self.assertEqual( self.assertEqual(
self.app.request.headers['x-remove-this-except-this'], 'value2') self.app.request.headers['x-remove-this-except-this'], 'value2')
@ -898,7 +898,7 @@ class TestTempURL(unittest.TestCase):
sig, expires)}) sig, expires)})
resp = req.get_response(self.tempurl) resp = req.get_response(self.tempurl)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertTrue('x-test-header-one-a' not in resp.headers) self.assertNotIn('x-test-header-one-a', resp.headers)
self.assertEqual(resp.headers['x-test-header-two-a'], 'value2') self.assertEqual(resp.headers['x-test-header-two-a'], 'value2')
def test_removed_outgoing_headers_match(self): def test_removed_outgoing_headers_match(self):
@ -918,7 +918,7 @@ class TestTempURL(unittest.TestCase):
resp = req.get_response(self.tempurl) resp = req.get_response(self.tempurl)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
self.assertEqual(resp.headers['x-test-header-one-a'], 'value1') self.assertEqual(resp.headers['x-test-header-one-a'], 'value1')
self.assertTrue('x-test-header-two-a' not in resp.headers) self.assertNotIn('x-test-header-two-a', resp.headers)
self.assertEqual(resp.headers['x-test-header-two-b'], 'value3') self.assertEqual(resp.headers['x-test-header-two-b'], 'value3')
def test_allow_trumps_outgoing_header_conflict(self): def test_allow_trumps_outgoing_header_conflict(self):
@ -1074,9 +1074,9 @@ class TestTempURL(unittest.TestCase):
resp = self._make_request('/v1/a/c/o', environ=environ).get_response( resp = self._make_request('/v1/a/c/o', environ=environ).get_response(
self.tempurl) self.tempurl)
self.assertEqual(resp.status_int, 401) self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' not in resp.body) self.assertNotIn('Temp URL invalid', resp.body)
self.assertTrue('Www-Authenticate' in resp.headers) self.assertTrue('Www-Authenticate' in resp.headers)
self.assertTrue('swift.auth_scheme' not in environ) self.assertNotIn('swift.auth_scheme', environ)
# Rejected by TempURL # Rejected by TempURL
environ = {'REQUEST_METHOD': 'PUT', environ = {'REQUEST_METHOD': 'PUT',
@ -1106,7 +1106,7 @@ class TestTempURL(unittest.TestCase):
None, {'incoming_remove_headers': irh, None, {'incoming_remove_headers': irh,
'incoming_allow_headers': iah} 'incoming_allow_headers': iah}
)._clean_incoming_headers(env) )._clean_incoming_headers(env)
self.assertTrue('HTTP_TEST_HEADER' not in env) self.assertNotIn('HTTP_TEST_HEADER', env)
irh = ['test-header-*'] irh = ['test-header-*']
iah = [] iah = []
@ -1116,8 +1116,8 @@ class TestTempURL(unittest.TestCase):
None, {'incoming_remove_headers': irh, None, {'incoming_remove_headers': irh,
'incoming_allow_headers': iah} 'incoming_allow_headers': iah}
)._clean_incoming_headers(env) )._clean_incoming_headers(env)
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env) self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
self.assertTrue('HTTP_TEST_HEADER_TWO' not in env) self.assertNotIn('HTTP_TEST_HEADER_TWO', env)
irh = ['test-header-*'] irh = ['test-header-*']
iah = ['test-header-two'] iah = ['test-header-two']
@ -1127,7 +1127,7 @@ class TestTempURL(unittest.TestCase):
None, {'incoming_remove_headers': irh, None, {'incoming_remove_headers': irh,
'incoming_allow_headers': iah} 'incoming_allow_headers': iah}
)._clean_incoming_headers(env) )._clean_incoming_headers(env)
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env) self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
self.assertTrue('HTTP_TEST_HEADER_TWO' in env) self.assertTrue('HTTP_TEST_HEADER_TWO' in env)
irh = ['test-header-*', 'test-other-header'] irh = ['test-header-*', 'test-other-header']
@ -1141,10 +1141,10 @@ class TestTempURL(unittest.TestCase):
None, {'incoming_remove_headers': irh, None, {'incoming_remove_headers': irh,
'incoming_allow_headers': iah} 'incoming_allow_headers': iah}
)._clean_incoming_headers(env) )._clean_incoming_headers(env)
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env) self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
self.assertTrue('HTTP_TEST_HEADER_TWO' in env) self.assertTrue('HTTP_TEST_HEADER_TWO' in env)
self.assertTrue('HTTP_TEST_OTHER_HEADER' not in env) self.assertNotIn('HTTP_TEST_OTHER_HEADER', env)
self.assertTrue('HTTP_TEST_HEADER_YES' not in env) self.assertNotIn('HTTP_TEST_HEADER_YES', env)
self.assertTrue('HTTP_TEST_HEADER_YES_THIS' in env) self.assertTrue('HTTP_TEST_HEADER_YES_THIS' in env)
def test_clean_outgoing_headers(self): def test_clean_outgoing_headers(self):
@ -1164,7 +1164,7 @@ class TestTempURL(unittest.TestCase):
None, None,
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah} {'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
)._clean_outgoing_headers(hdrs.items())) )._clean_outgoing_headers(hdrs.items()))
self.assertTrue('test-header' not in hdrs) self.assertNotIn('test-header', hdrs)
orh = ['test-header-*'] orh = ['test-header-*']
oah = [] oah = []
@ -1174,8 +1174,8 @@ class TestTempURL(unittest.TestCase):
None, None,
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah} {'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
)._clean_outgoing_headers(hdrs.items())) )._clean_outgoing_headers(hdrs.items()))
self.assertTrue('test-header-one' not in hdrs) self.assertNotIn('test-header-one', hdrs)
self.assertTrue('test-header-two' not in hdrs) self.assertNotIn('test-header-two', hdrs)
orh = ['test-header-*'] orh = ['test-header-*']
oah = ['test-header-two'] oah = ['test-header-two']
@ -1185,7 +1185,7 @@ class TestTempURL(unittest.TestCase):
None, None,
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah} {'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
)._clean_outgoing_headers(hdrs.items())) )._clean_outgoing_headers(hdrs.items()))
self.assertTrue('test-header-one' not in hdrs) self.assertNotIn('test-header-one', hdrs)
self.assertTrue('test-header-two' in hdrs) self.assertTrue('test-header-two' in hdrs)
orh = ['test-header-*', 'test-other-header'] orh = ['test-header-*', 'test-other-header']
@ -1199,10 +1199,10 @@ class TestTempURL(unittest.TestCase):
None, None,
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah} {'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
)._clean_outgoing_headers(hdrs.items())) )._clean_outgoing_headers(hdrs.items()))
self.assertTrue('test-header-one' not in hdrs) self.assertNotIn('test-header-one', hdrs)
self.assertTrue('test-header-two' in hdrs) self.assertTrue('test-header-two' in hdrs)
self.assertTrue('test-other-header' not in hdrs) self.assertNotIn('test-other-header', hdrs)
self.assertTrue('test-header-yes' not in hdrs) self.assertNotIn('test-header-yes', hdrs)
self.assertTrue('test-header-yes-this' in hdrs) self.assertTrue('test-header-yes-this' in hdrs)
def test_unicode_metadata_value(self): def test_unicode_metadata_value(self):

View File

@ -1131,7 +1131,7 @@ class TestDatabaseBroker(unittest.TestCase):
self.assertTrue('First' in broker.metadata) self.assertTrue('First' in broker.metadata)
self.assertEqual(broker.metadata['First'], self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp]) [first_value, first_timestamp])
self.assertTrue('Second' not in broker.metadata) self.assertNotIn('Second', broker.metadata)
@patch.object(DatabaseBroker, 'validate_metadata') @patch.object(DatabaseBroker, 'validate_metadata')
def test_validate_metadata_is_called_from_update_metadata(self, mock): def test_validate_metadata_is_called_from_update_metadata(self, mock):

View File

@ -528,8 +528,8 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(conn.req_headers['user-agent'], self.user_agent) self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
self.assertEqual('bar', conn.req_headers.get('x-foo')) self.assertEqual('bar', conn.req_headers.get('x-foo'))
self.assertTrue('x-timestamp' not in conn.req_headers, self.assertNotIn('x-timestamp', conn.req_headers,
'x-timestamp was in HEAD request headers') 'x-timestamp was in HEAD request headers')
self.assertEqual(headers, resp) self.assertEqual(headers, resp)
def test_direct_head_object_error(self): def test_direct_head_object_error(self):

View File

@ -741,8 +741,8 @@ class TestServer(unittest.TestCase):
manager.os = MockOs([2]) manager.os = MockOs([2])
# test pid not running # test pid not running
pids = server.signal_pids(signal.SIG_DFL) pids = server.signal_pids(signal.SIG_DFL)
self.assertTrue(1 not in pids) self.assertNotIn(1, pids)
self.assertTrue(1 not in manager.os.pid_sigs) self.assertNotIn(1, manager.os.pid_sigs)
# test remove stale pid file # test remove stale pid file
self.assertFalse(os.path.exists( self.assertFalse(os.path.exists(
self.join_run_dir('proxy-server.pid'))) self.join_run_dir('proxy-server.pid')))
@ -818,8 +818,8 @@ class TestServer(unittest.TestCase):
running_pids = server.get_running_pids() running_pids = server.get_running_pids()
self.assertEqual(len(running_pids), 1) self.assertEqual(len(running_pids), 1)
self.assertTrue(1 in running_pids) self.assertTrue(1 in running_pids)
self.assertTrue(2 not in running_pids) self.assertNotIn(2, running_pids)
self.assertTrue(3 not in running_pids) self.assertNotIn(3, running_pids)
# test persistent running pid files # test persistent running pid files
self.assertTrue(os.path.exists( self.assertTrue(os.path.exists(
os.path.join(manager.RUN_DIR, 'test-server1.pid'))) os.path.join(manager.RUN_DIR, 'test-server1.pid')))
@ -857,7 +857,7 @@ class TestServer(unittest.TestCase):
self.assertTrue(1 in running_pids) self.assertTrue(1 in running_pids)
# no other pids returned # no other pids returned
for n in (2, 3, 4): for n in (2, 3, 4):
self.assertTrue(n not in running_pids) self.assertNotIn(n, running_pids)
# assert stale pids for other servers ignored # assert stale pids for other servers ignored
manager.os = MockOs([1]) # only thing-doer is running manager.os = MockOs([1]) # only thing-doer is running
running_pids = server.get_running_pids() running_pids = server.get_running_pids()
@ -922,7 +922,7 @@ class TestServer(unittest.TestCase):
self.assertEqual(manager.os.pid_sigs[pid], self.assertEqual(manager.os.pid_sigs[pid],
[signal.SIGTERM]) [signal.SIGTERM])
# and the other pid is of course not signaled # and the other pid is of course not signaled
self.assertTrue(1 not in manager.os.pid_sigs) self.assertNotIn(1, manager.os.pid_sigs)
def test_status(self): def test_status(self):
conf_files = ( conf_files = (
@ -1245,7 +1245,7 @@ class TestServer(unittest.TestCase):
self.assertTrue('mock process started' in output) self.assertTrue('mock process started' in output)
self.assertTrue('setup complete' in output) self.assertTrue('setup complete' in output)
# make sure we don't get prints after stdout was closed # make sure we don't get prints after stdout was closed
self.assertTrue('mock process finished' not in output) self.assertNotIn('mock process finished', output)
# test process which fails to start # test process which fails to start
with MockProcess(fail_to_start=True) as proc: with MockProcess(fail_to_start=True) as proc:
server.procs = [proc] server.procs = [proc]
@ -1386,7 +1386,7 @@ class TestServer(unittest.TestCase):
self.assertEqual(mock_spawn.kwargs, [expected]) self.assertEqual(mock_spawn.kwargs, [expected])
output = pop_stream(f) output = pop_stream(f)
self.assertTrue('Starting' in output) self.assertTrue('Starting' in output)
self.assertTrue('once' not in output) self.assertNotIn('once', output)
# test multi-server kwarg once # test multi-server kwarg once
server = manager.Server('object-replicator') server = manager.Server('object-replicator')
with temptree([], []) as proc_dir: with temptree([], []) as proc_dir:

View File

@ -270,7 +270,7 @@ class TestMatch(unittest.TestCase):
self.assertEqual(match.tags, set(('a', 'b'))) self.assertEqual(match.tags, set(('a', 'b')))
self.assertTrue('a' in match) self.assertTrue('a' in match)
self.assertTrue('b' in match) self.assertTrue('b' in match)
self.assertTrue('c' not in match) self.assertNotIn('c', match)
def test_match_star(self): def test_match_star(self):
match = swift.common.swob.Match('"a", "*"') match = swift.common.swob.Match('"a", "*"')
@ -283,7 +283,7 @@ class TestMatch(unittest.TestCase):
self.assertEqual(match.tags, set(('a', 'b'))) self.assertEqual(match.tags, set(('a', 'b')))
self.assertTrue('a' in match) self.assertTrue('a' in match)
self.assertTrue('b' in match) self.assertTrue('b' in match)
self.assertTrue('c' not in match) self.assertNotIn('c', match)
class TestTransferEncoding(unittest.TestCase): class TestTransferEncoding(unittest.TestCase):
@ -724,7 +724,7 @@ class TestRequest(unittest.TestCase):
req = swift.common.swob.Request.blank('/') req = swift.common.swob.Request.blank('/')
resp = req.get_response(test_app) resp = req.get_response(test_app)
self.assertTrue('Www-Authenticate' not in resp.headers) self.assertNotIn('Www-Authenticate', resp.headers)
def test_properties(self): def test_properties(self):
req = swift.common.swob.Request.blank('/hi/there', body='hi') req = swift.common.swob.Request.blank('/hi/there', body='hi')
@ -744,7 +744,7 @@ class TestRequest(unittest.TestCase):
self.assertTrue('Range' in req.headers) self.assertTrue('Range' in req.headers)
req.range = None req.range = None
self.assertTrue('Range' not in req.headers) self.assertNotIn('Range', req.headers)
def test_datetime_properties(self): def test_datetime_properties(self):
req = swift.common.swob.Request.blank('/hi/there', body='hi') req = swift.common.swob.Request.blank('/hi/there', body='hi')
@ -761,7 +761,7 @@ class TestRequest(unittest.TestCase):
self.assertTrue('If-Unmodified-Since' in req.headers) self.assertTrue('If-Unmodified-Since' in req.headers)
req.if_unmodified_since = None req.if_unmodified_since = None
self.assertTrue('If-Unmodified-Since' not in req.headers) self.assertNotIn('If-Unmodified-Since', req.headers)
too_big_date_list = list(datetime.datetime.max.timetuple()) too_big_date_list = list(datetime.datetime.max.timetuple())
too_big_date_list[0] += 1 # bump up the year too_big_date_list[0] += 1 # bump up the year
@ -1032,12 +1032,12 @@ class TestResponse(unittest.TestCase):
self.assertEqual(resp.location, 'something') self.assertEqual(resp.location, 'something')
self.assertTrue('Location' in resp.headers) self.assertTrue('Location' in resp.headers)
resp.location = None resp.location = None
self.assertTrue('Location' not in resp.headers) self.assertNotIn('Location', resp.headers)
resp.content_type = 'text/plain' resp.content_type = 'text/plain'
self.assertTrue('Content-Type' in resp.headers) self.assertTrue('Content-Type' in resp.headers)
resp.content_type = None resp.content_type = None
self.assertTrue('Content-Type' not in resp.headers) self.assertNotIn('Content-Type', resp.headers)
def test_empty_body(self): def test_empty_body(self):
resp = self._get_response() resp = self._get_response()
@ -1359,7 +1359,7 @@ class TestResponse(unittest.TestCase):
self.assertTrue('etag' in resp.headers) self.assertTrue('etag' in resp.headers)
resp.etag = None resp.etag = None
self.assertTrue('etag' not in resp.headers) self.assertNotIn('etag', resp.headers)
def test_host_url_default(self): def test_host_url_default(self):
resp = self._get_response() resp = self._get_response()

View File

@ -1314,7 +1314,7 @@ class TestUtils(unittest.TestCase):
self.assertEqual(conf, conf_file) self.assertEqual(conf, conf_file)
# assert defaults # assert defaults
self.assertEqual(options['verbose'], False) self.assertEqual(options['verbose'], False)
self.assertTrue('once' not in options) self.assertNotIn('once', options)
# assert verbose as option # assert verbose as option
conf, options = utils.parse_options(test_args=[conf_file, '-v']) conf, options = utils.parse_options(test_args=[conf_file, '-v'])
self.assertEqual(options['verbose'], True) self.assertEqual(options['verbose'], True)
@ -1549,7 +1549,7 @@ class TestUtils(unittest.TestCase):
for en in (errno.EIO, errno.ENOSPC): for en in (errno.EIO, errno.ENOSPC):
log_exception(OSError(en, 'my %s error message' % en)) log_exception(OSError(en, 'my %s error message' % en))
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('my %s error message' % en in log_msg) self.assertTrue('my %s error message' % en in log_msg)
# unfiltered # unfiltered
log_exception(OSError()) log_exception(OSError())
@ -1559,19 +1559,19 @@ class TestUtils(unittest.TestCase):
log_exception(socket.error(errno.ECONNREFUSED, log_exception(socket.error(errno.ECONNREFUSED,
'my error message')) 'my error message'))
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('errno.ECONNREFUSED message test' not in log_msg) self.assertNotIn('errno.ECONNREFUSED message test', log_msg)
self.assertTrue('Connection refused' in log_msg) self.assertTrue('Connection refused' in log_msg)
log_exception(socket.error(errno.EHOSTUNREACH, log_exception(socket.error(errno.EHOSTUNREACH,
'my error message')) 'my error message'))
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('my error message' not in log_msg) self.assertNotIn('my error message', log_msg)
self.assertTrue('Host unreachable' in log_msg) self.assertTrue('Host unreachable' in log_msg)
log_exception(socket.error(errno.ETIMEDOUT, 'my error message')) log_exception(socket.error(errno.ETIMEDOUT, 'my error message'))
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('my error message' not in log_msg) self.assertNotIn('my error message', log_msg)
self.assertTrue('Connection timeout' in log_msg) self.assertTrue('Connection timeout' in log_msg)
# unfiltered # unfiltered
log_exception(socket.error(0, 'my error message')) log_exception(socket.error(0, 'my error message'))
@ -1583,16 +1583,16 @@ class TestUtils(unittest.TestCase):
connection_timeout = ConnectionTimeout(42, 'my error message') connection_timeout = ConnectionTimeout(42, 'my error message')
log_exception(connection_timeout) log_exception(connection_timeout)
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('ConnectionTimeout' in log_msg) self.assertTrue('ConnectionTimeout' in log_msg)
self.assertTrue('(42s)' in log_msg) self.assertTrue('(42s)' in log_msg)
self.assertTrue('my error message' not in log_msg) self.assertNotIn('my error message', log_msg)
connection_timeout.cancel() connection_timeout.cancel()
message_timeout = MessageTimeout(42, 'my error message') message_timeout = MessageTimeout(42, 'my error message')
log_exception(message_timeout) log_exception(message_timeout)
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('Traceback' not in log_msg) self.assertNotIn('Traceback', log_msg)
self.assertTrue('MessageTimeout' in log_msg) self.assertTrue('MessageTimeout' in log_msg)
self.assertTrue('(42s)' in log_msg) self.assertTrue('(42s)' in log_msg)
self.assertTrue('my error message' in log_msg) self.assertTrue('my error message' in log_msg)
@ -1683,7 +1683,7 @@ class TestUtils(unittest.TestCase):
logger.error('my error message') logger.error('my error message')
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('my error message' in log_msg) self.assertTrue('my error message' in log_msg)
self.assertTrue('txn' not in log_msg) self.assertNotIn('txn', log_msg)
logger.txn_id = '12345' logger.txn_id = '12345'
logger.error('test') logger.error('test')
log_msg = strip_value(sio) log_msg = strip_value(sio)
@ -1709,7 +1709,7 @@ class TestUtils(unittest.TestCase):
logger.error('my error message') logger.error('my error message')
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('my error message' in log_msg) self.assertTrue('my error message' in log_msg)
self.assertTrue('client_ip' not in log_msg) self.assertNotIn('client_ip', log_msg)
logger.client_ip = '1.2.3.4' logger.client_ip = '1.2.3.4'
logger.error('test') logger.error('test')
log_msg = strip_value(sio) log_msg = strip_value(sio)
@ -1719,8 +1719,8 @@ class TestUtils(unittest.TestCase):
self.assertEqual(logger.client_ip, '1.2.3.4') self.assertEqual(logger.client_ip, '1.2.3.4')
logger.info('test') logger.info('test')
log_msg = strip_value(sio) log_msg = strip_value(sio)
self.assertTrue('client_ip' not in log_msg) self.assertNotIn('client_ip', log_msg)
self.assertTrue('1.2.3.4' not in log_msg) self.assertNotIn('1.2.3.4', log_msg)
# test client_ip (and txn) already in message # test client_ip (and txn) already in message
self.assertEqual(logger.client_ip, '1.2.3.4') self.assertEqual(logger.client_ip, '1.2.3.4')
logger.warning('test 1.2.3.4 test 12345') logger.warning('test 1.2.3.4 test 12345')
@ -2128,7 +2128,7 @@ log_name = %(yarr)s'''
for func in required_func_calls: for func in required_func_calls:
self.assertTrue(utils.os.called_funcs[func]) self.assertTrue(utils.os.called_funcs[func])
for func in bad_func_calls: for func in bad_func_calls:
self.assertTrue(func not in utils.os.called_funcs) self.assertNotIn(func, utils.os.called_funcs)
@reset_logger_state @reset_logger_state
def test_capture_stdio(self): def test_capture_stdio(self):
@ -4022,7 +4022,7 @@ class TestSwiftInfo(unittest.TestCase):
info = utils.get_swift_info() info = utils.get_swift_info()
self.assertTrue('admin' not in info) self.assertNotIn('admin', info)
self.assertTrue('swift' in info) self.assertTrue('swift' in info)
self.assertTrue('foo' in info['swift']) self.assertTrue('foo' in info['swift'])
@ -4041,19 +4041,19 @@ class TestSwiftInfo(unittest.TestCase):
info = utils.get_swift_info(disallowed_sections=['cap1', 'cap3']) info = utils.get_swift_info(disallowed_sections=['cap1', 'cap3'])
self.assertTrue('admin' not in info) self.assertNotIn('admin', info)
self.assertTrue('swift' in info) self.assertTrue('swift' in info)
self.assertTrue('foo' in info['swift']) self.assertTrue('foo' in info['swift'])
self.assertEqual(info['swift']['foo'], 'bar') self.assertEqual(info['swift']['foo'], 'bar')
self.assertTrue('cap1' not in info) self.assertNotIn('cap1', info)
self.assertTrue('cap2' in info) self.assertTrue('cap2' in info)
self.assertTrue('cap2_foo' in info['cap2']) self.assertTrue('cap2_foo' in info['cap2'])
self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar') self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar')
self.assertTrue('cap3' not in info) self.assertNotIn('cap3', info)
def test_register_swift_admin_info(self): def test_register_swift_admin_info(self):
utils.register_swift_info(admin=True, admin_foo='admin_bar') utils.register_swift_info(admin=True, admin_foo='admin_bar')
@ -4077,8 +4077,8 @@ class TestSwiftInfo(unittest.TestCase):
self.assertEqual( self.assertEqual(
utils._swift_admin_info['cap1']['ac1_lorem'], 'ac1_ipsum') utils._swift_admin_info['cap1']['ac1_lorem'], 'ac1_ipsum')
self.assertTrue('swift' not in utils._swift_info) self.assertNotIn('swift', utils._swift_info)
self.assertTrue('cap1' not in utils._swift_info) self.assertNotIn('cap1', utils._swift_info)
def test_get_swift_admin_info(self): def test_get_swift_admin_info(self):
utils._swift_info = {'swift': {'foo': 'bar'}, utils._swift_info = {'swift': {'foo': 'bar'},
@ -4116,20 +4116,20 @@ class TestSwiftInfo(unittest.TestCase):
self.assertEqual(info['admin']['admin_cap1']['ac1_foo'], 'ac1_bar') self.assertEqual(info['admin']['admin_cap1']['ac1_foo'], 'ac1_bar')
self.assertTrue('disallowed_sections' in info['admin']) self.assertTrue('disallowed_sections' in info['admin'])
self.assertTrue('cap1' in info['admin']['disallowed_sections']) self.assertTrue('cap1' in info['admin']['disallowed_sections'])
self.assertTrue('cap2' not in info['admin']['disallowed_sections']) self.assertNotIn('cap2', info['admin']['disallowed_sections'])
self.assertTrue('cap3' in info['admin']['disallowed_sections']) self.assertTrue('cap3' in info['admin']['disallowed_sections'])
self.assertTrue('swift' in info) self.assertTrue('swift' in info)
self.assertTrue('foo' in info['swift']) self.assertTrue('foo' in info['swift'])
self.assertEqual(info['swift']['foo'], 'bar') self.assertEqual(info['swift']['foo'], 'bar')
self.assertTrue('cap1' not in info) self.assertNotIn('cap1', info)
self.assertTrue('cap2' in info) self.assertTrue('cap2' in info)
self.assertTrue('cap2_foo' in info['cap2']) self.assertTrue('cap2_foo' in info['cap2'])
self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar') self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar')
self.assertTrue('cap3' not in info) self.assertNotIn('cap3', info)
def test_get_swift_admin_info_with_disallowed_sub_sections(self): def test_get_swift_admin_info_with_disallowed_sub_sections(self):
utils._swift_info = {'swift': {'foo': 'bar'}, utils._swift_info = {'swift': {'foo': 'bar'},
@ -4144,10 +4144,10 @@ class TestSwiftInfo(unittest.TestCase):
info = utils.get_swift_info( info = utils.get_swift_info(
admin=True, disallowed_sections=['cap1.cap1_foo', 'cap3', admin=True, disallowed_sections=['cap1.cap1_foo', 'cap3',
'cap4.a.b.c']) 'cap4.a.b.c'])
self.assertTrue('cap3' not in info) self.assertNotIn('cap3', info)
self.assertEqual(info['cap1']['cap1_moo'], 'cap1_baa') self.assertEqual(info['cap1']['cap1_moo'], 'cap1_baa')
self.assertTrue('cap1_foo' not in info['cap1']) self.assertNotIn('cap1_foo', info['cap1'])
self.assertTrue('c' not in info['cap4']['a']['b']) self.assertNotIn('c', info['cap4']['a']['b'])
self.assertEqual(info['cap4']['a']['b.c'], 'b.c') self.assertEqual(info['cap4']['a']['b.c'], 'b.c')
def test_get_swift_info_with_unmatched_disallowed_sections(self): def test_get_swift_info_with_unmatched_disallowed_sections(self):

View File

@ -137,8 +137,8 @@ class TestContainerController(unittest.TestCase):
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'}) '/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller) response = req.get_response(self.controller)
self.assertTrue(response.status.startswith('204')) self.assertTrue(response.status.startswith('204'))
self.assertTrue('x-container-read' not in response.headers) self.assertNotIn('x-container-read', response.headers)
self.assertTrue('x-container-write' not in response.headers) self.assertNotIn('x-container-write', response.headers)
# Ensure POSTing acls works # Ensure POSTing acls works
req = Request.blank( req = Request.blank(
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'POST'}, '/sda1/p/a/c', environ={'REQUEST_METHOD': 'POST'},
@ -164,8 +164,8 @@ class TestContainerController(unittest.TestCase):
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'}) '/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
response = req.get_response(self.controller) response = req.get_response(self.controller)
self.assertTrue(response.status.startswith('204')) self.assertTrue(response.status.startswith('204'))
self.assertTrue('x-container-read' not in response.headers) self.assertNotIn('x-container-read', response.headers)
self.assertTrue('x-container-write' not in response.headers) self.assertNotIn('x-container-write', response.headers)
# Ensure PUTing acls works # Ensure PUTing acls works
req = Request.blank( req = Request.blank(
'/sda1/p/a/c2', environ={'REQUEST_METHOD': 'PUT'}, '/sda1/p/a/c2', environ={'REQUEST_METHOD': 'PUT'},
@ -737,7 +737,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'}) req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue('x-container-meta-test' not in resp.headers) self.assertNotIn('x-container-meta-test', resp.headers)
def test_PUT_GET_sys_metadata(self): def test_PUT_GET_sys_metadata(self):
prefix = get_sys_meta_prefix('container') prefix = get_sys_meta_prefix('container')
@ -795,7 +795,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'}) req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue(key.lower() not in resp.headers) self.assertNotIn(key.lower(), resp.headers)
def test_PUT_invalid_partition(self): def test_PUT_invalid_partition(self):
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'PUT', req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'PUT',
@ -878,7 +878,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'}) req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue('x-container-meta-test' not in resp.headers) self.assertNotIn('x-container-meta-test', resp.headers)
self.assertEqual(resp.headers.get('x-put-timestamp'), self.assertEqual(resp.headers.get('x-put-timestamp'),
'0000000004.00000') '0000000004.00000')
@ -930,7 +930,7 @@ class TestContainerController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'}) req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
resp = req.get_response(self.controller) resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
self.assertTrue(key.lower() not in resp.headers) self.assertNotIn(key.lower(), resp.headers)
def test_POST_invalid_partition(self): def test_POST_invalid_partition(self):
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'POST', req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'POST',

View File

@ -373,7 +373,7 @@ class TestObjectExpirer(TestCase):
'Pass beginning; 1 possible containers; 2 possible objects', 'Pass beginning; 1 possible containers; 2 possible objects',
'Pass completed in 0s; 0 objects expired', 'Pass completed in 0s; 0 objects expired',
]) ])
self.assertTrue('error' not in logs) self.assertNotIn('error', logs)
# Reverse test to be sure it still would blow up the way expected. # Reverse test to be sure it still would blow up the way expected.
fake_swift = InternalClient([{'name': str(int(time() - 86400))}]) fake_swift = InternalClient([{'name': str(int(time() - 86400))}])
@ -414,7 +414,7 @@ class TestObjectExpirer(TestCase):
x = expirer.ObjectExpirer(self.conf, logger=self.logger, x = expirer.ObjectExpirer(self.conf, logger=self.logger,
swift=fake_swift) swift=fake_swift)
x.run_once() x.run_once()
self.assertTrue('error' not in x.logger.all_log_lines()) self.assertNotIn('error', x.logger.all_log_lines())
self.assertEqual(x.logger.get_lines_for_level('info'), [ self.assertEqual(x.logger.get_lines_for_level('info'), [
'Pass beginning; 1 possible containers; 2 possible objects', 'Pass beginning; 1 possible containers; 2 possible objects',
'Pass completed in 0s; 0 objects expired', 'Pass completed in 0s; 0 objects expired',