Modify assert
For example: self.assertEqual(a,None) is equal to self.assertIsNone(a) Change-Id: I063145d034979cf3d36645a00a30cc27defac7c4
This commit is contained in:
parent
20ec344699
commit
d460db84ed
@ -59,7 +59,7 @@ class TestSwiftPostObject(unittest.TestCase):
|
|||||||
spo = self.spo('obj_name')
|
spo = self.spo('obj_name')
|
||||||
|
|
||||||
self.assertEqual(spo.object_name, 'obj_name')
|
self.assertEqual(spo.object_name, 'obj_name')
|
||||||
self.assertEqual(spo.options, None)
|
self.assertIsNone(spo.options)
|
||||||
|
|
||||||
def test_create_with_invalid_name(self):
|
def test_create_with_invalid_name(self):
|
||||||
# empty strings are not allowed as names
|
# empty strings are not allowed as names
|
||||||
@ -81,10 +81,10 @@ class TestSwiftReader(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(sr._path, 'path')
|
self.assertEqual(sr._path, 'path')
|
||||||
self.assertEqual(sr._body, 'body')
|
self.assertEqual(sr._body, 'body')
|
||||||
self.assertEqual(sr._content_length, None)
|
self.assertIsNone(sr._content_length)
|
||||||
self.assertEqual(sr._expected_etag, None)
|
self.assertIsNone(sr._expected_etag)
|
||||||
|
|
||||||
self.assertNotEqual(sr._actual_md5, None)
|
self.assertIsNotNone(sr._actual_md5)
|
||||||
self.assertIs(type(sr._actual_md5), self.md5_type)
|
self.assertIs(type(sr._actual_md5), self.md5_type)
|
||||||
|
|
||||||
def test_create_with_large_object_headers(self):
|
def test_create_with_large_object_headers(self):
|
||||||
@ -92,25 +92,25 @@ class TestSwiftReader(unittest.TestCase):
|
|||||||
sr = self.sr('path', 'body', {'x-object-manifest': 'test'})
|
sr = self.sr('path', 'body', {'x-object-manifest': 'test'})
|
||||||
self.assertEqual(sr._path, 'path')
|
self.assertEqual(sr._path, 'path')
|
||||||
self.assertEqual(sr._body, 'body')
|
self.assertEqual(sr._body, 'body')
|
||||||
self.assertEqual(sr._content_length, None)
|
self.assertIsNone(sr._content_length)
|
||||||
self.assertEqual(sr._expected_etag, None)
|
self.assertIsNone(sr._expected_etag)
|
||||||
self.assertEqual(sr._actual_md5, None)
|
self.assertIsNone(sr._actual_md5)
|
||||||
|
|
||||||
sr = self.sr('path', 'body', {'x-static-large-object': 'test'})
|
sr = self.sr('path', 'body', {'x-static-large-object': 'test'})
|
||||||
self.assertEqual(sr._path, 'path')
|
self.assertEqual(sr._path, 'path')
|
||||||
self.assertEqual(sr._body, 'body')
|
self.assertEqual(sr._body, 'body')
|
||||||
self.assertEqual(sr._content_length, None)
|
self.assertIsNone(sr._content_length)
|
||||||
self.assertEqual(sr._expected_etag, None)
|
self.assertIsNone(sr._expected_etag)
|
||||||
self.assertEqual(sr._actual_md5, None)
|
self.assertIsNone(sr._actual_md5)
|
||||||
|
|
||||||
def test_create_with_ignore_checksum(self):
|
def test_create_with_ignore_checksum(self):
|
||||||
# md5 should not be initialized if checksum is False
|
# md5 should not be initialized if checksum is False
|
||||||
sr = self.sr('path', 'body', {}, False)
|
sr = self.sr('path', 'body', {}, False)
|
||||||
self.assertEqual(sr._path, 'path')
|
self.assertEqual(sr._path, 'path')
|
||||||
self.assertEqual(sr._body, 'body')
|
self.assertEqual(sr._body, 'body')
|
||||||
self.assertEqual(sr._content_length, None)
|
self.assertIsNone(sr._content_length)
|
||||||
self.assertEqual(sr._expected_etag, None)
|
self.assertIsNone(sr._expected_etag)
|
||||||
self.assertEqual(sr._actual_md5, None)
|
self.assertIsNone(sr._actual_md5)
|
||||||
|
|
||||||
def test_create_with_content_length(self):
|
def test_create_with_content_length(self):
|
||||||
sr = self.sr('path', 'body', {'content-length': 5})
|
sr = self.sr('path', 'body', {'content-length': 5})
|
||||||
@ -118,9 +118,9 @@ class TestSwiftReader(unittest.TestCase):
|
|||||||
self.assertEqual(sr._path, 'path')
|
self.assertEqual(sr._path, 'path')
|
||||||
self.assertEqual(sr._body, 'body')
|
self.assertEqual(sr._body, 'body')
|
||||||
self.assertEqual(sr._content_length, 5)
|
self.assertEqual(sr._content_length, 5)
|
||||||
self.assertEqual(sr._expected_etag, None)
|
self.assertIsNone(sr._expected_etag)
|
||||||
|
|
||||||
self.assertNotEqual(sr._actual_md5, None)
|
self.assertIsNotNone(sr._actual_md5)
|
||||||
self.assertIs(type(sr._actual_md5), self.md5_type)
|
self.assertIs(type(sr._actual_md5), self.md5_type)
|
||||||
|
|
||||||
# Check Contentlength raises error if it isn't an integer
|
# Check Contentlength raises error if it isn't an integer
|
||||||
@ -401,10 +401,10 @@ class TestSwiftError(unittest.TestCase):
|
|||||||
se = SwiftError(5)
|
se = SwiftError(5)
|
||||||
|
|
||||||
self.assertEqual(se.value, 5)
|
self.assertEqual(se.value, 5)
|
||||||
self.assertEqual(se.container, None)
|
self.assertIsNone(se.container)
|
||||||
self.assertEqual(se.obj, None)
|
self.assertIsNone(se.obj)
|
||||||
self.assertEqual(se.segment, None)
|
self.assertIsNone(se.segment)
|
||||||
self.assertEqual(se.exception, None)
|
self.assertIsNone(se.exception)
|
||||||
|
|
||||||
self.assertEqual(str(se), '5')
|
self.assertEqual(str(se), '5')
|
||||||
|
|
||||||
@ -526,12 +526,12 @@ class TestSwiftUploadObject(unittest.TestCase):
|
|||||||
suo = self.suo('source')
|
suo = self.suo('source')
|
||||||
self.assertEqual(suo.source, 'source')
|
self.assertEqual(suo.source, 'source')
|
||||||
self.assertEqual(suo.object_name, 'source')
|
self.assertEqual(suo.object_name, 'source')
|
||||||
self.assertEqual(suo.options, None)
|
self.assertIsNone(suo.options)
|
||||||
|
|
||||||
suo = self.suo('source', 'obj_name')
|
suo = self.suo('source', 'obj_name')
|
||||||
self.assertEqual(suo.source, 'source')
|
self.assertEqual(suo.source, 'source')
|
||||||
self.assertEqual(suo.object_name, 'obj_name')
|
self.assertEqual(suo.object_name, 'obj_name')
|
||||||
self.assertEqual(suo.options, None)
|
self.assertIsNone(suo.options)
|
||||||
|
|
||||||
suo = self.suo('source', 'obj_name', {'opt': '123'})
|
suo = self.suo('source', 'obj_name', {'opt': '123'})
|
||||||
self.assertEqual(suo.source, 'source')
|
self.assertEqual(suo.source, 'source')
|
||||||
@ -550,7 +550,7 @@ class TestSwiftUploadObject(unittest.TestCase):
|
|||||||
suo = self.suo(mock_file, 'obj_name')
|
suo = self.suo(mock_file, 'obj_name')
|
||||||
self.assertEqual(suo.source, mock_file)
|
self.assertEqual(suo.source, mock_file)
|
||||||
self.assertEqual(suo.object_name, 'obj_name')
|
self.assertEqual(suo.object_name, 'obj_name')
|
||||||
self.assertEqual(suo.options, None)
|
self.assertIsNone(suo.options)
|
||||||
|
|
||||||
suo = self.suo(mock_file, 'obj_name', {'opt': '123'})
|
suo = self.suo(mock_file, 'obj_name', {'opt': '123'})
|
||||||
self.assertEqual(suo.source, mock_file)
|
self.assertEqual(suo.source, mock_file)
|
||||||
@ -559,9 +559,9 @@ class TestSwiftUploadObject(unittest.TestCase):
|
|||||||
|
|
||||||
def test_create_with_no_source(self):
|
def test_create_with_no_source(self):
|
||||||
suo = self.suo(None, 'obj_name')
|
suo = self.suo(None, 'obj_name')
|
||||||
self.assertEqual(suo.source, None)
|
self.assertIsNone(suo.source)
|
||||||
self.assertEqual(suo.object_name, 'obj_name')
|
self.assertEqual(suo.object_name, 'obj_name')
|
||||||
self.assertEqual(suo.options, None)
|
self.assertIsNone(suo.options)
|
||||||
|
|
||||||
# Check error is raised if source is None without an object name
|
# Check error is raised if source is None without an object name
|
||||||
self.assertRaises(SwiftError, self.suo, None)
|
self.assertRaises(SwiftError, self.suo, None)
|
||||||
@ -1868,7 +1868,7 @@ class TestServiceDownload(_TestServiceBase):
|
|||||||
mock_down_cont.assert_not_called()
|
mock_down_cont.assert_not_called()
|
||||||
|
|
||||||
next(service.download('c', options=self.opts), None)
|
next(service.download('c', options=self.opts), None)
|
||||||
self.assertEqual(True, mock_down_cont.called)
|
self.assertTrue(mock_down_cont.called)
|
||||||
|
|
||||||
def test_download_with_output_dir(self):
|
def test_download_with_output_dir(self):
|
||||||
with mock.patch('swiftclient.service.Connection') as mock_conn:
|
with mock.patch('swiftclient.service.Connection') as mock_conn:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user