summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzheng yin <yin.zheng@easystack.cn>2016-07-25 11:58:28 +0800
committerzheng yin <yin.zheng@easystack.cn>2016-07-26 22:23:43 +0800
commitd460db84edb11cd57ed12b092a21224e870a4228 (patch)
tree8f3f2a1d9e6e7c12d2c629ad35b29fd408e66318
parent20ec344699b1ee0674319879e6ecbbfb3231432c (diff)
downloadpython-swiftclient-d460db84edb11cd57ed12b092a21224e870a4228.tar.gz
Modify assert
For example: self.assertEqual(a,None) is equal to self.assertIsNone(a) Change-Id: I063145d034979cf3d36645a00a30cc27defac7c4
-rw-r--r--tests/unit/test_service.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py
index 75f8961..2e7acf9 100644
--- a/tests/unit/test_service.py
+++ b/tests/unit/test_service.py
@@ -59,7 +59,7 @@ class TestSwiftPostObject(unittest.TestCase):
spo = self.spo('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):
# empty strings are not allowed as names
@@ -81,10 +81,10 @@ class TestSwiftReader(unittest.TestCase):
self.assertEqual(sr._path, 'path')
self.assertEqual(sr._body, 'body')
- self.assertEqual(sr._content_length, None)
- self.assertEqual(sr._expected_etag, None)
+ self.assertIsNone(sr._content_length)
+ 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)
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'})
self.assertEqual(sr._path, 'path')
self.assertEqual(sr._body, 'body')
- self.assertEqual(sr._content_length, None)
- self.assertEqual(sr._expected_etag, None)
- self.assertEqual(sr._actual_md5, None)
+ self.assertIsNone(sr._content_length)
+ self.assertIsNone(sr._expected_etag)
+ self.assertIsNone(sr._actual_md5)
sr = self.sr('path', 'body', {'x-static-large-object': 'test'})
self.assertEqual(sr._path, 'path')
self.assertEqual(sr._body, 'body')
- self.assertEqual(sr._content_length, None)
- self.assertEqual(sr._expected_etag, None)
- self.assertEqual(sr._actual_md5, None)
+ self.assertIsNone(sr._content_length)
+ self.assertIsNone(sr._expected_etag)
+ self.assertIsNone(sr._actual_md5)
def test_create_with_ignore_checksum(self):
# md5 should not be initialized if checksum is False
sr = self.sr('path', 'body', {}, False)
self.assertEqual(sr._path, 'path')
self.assertEqual(sr._body, 'body')
- self.assertEqual(sr._content_length, None)
- self.assertEqual(sr._expected_etag, None)
- self.assertEqual(sr._actual_md5, None)
+ self.assertIsNone(sr._content_length)
+ self.assertIsNone(sr._expected_etag)
+ self.assertIsNone(sr._actual_md5)
def test_create_with_content_length(self):
sr = self.sr('path', 'body', {'content-length': 5})
@@ -118,9 +118,9 @@ class TestSwiftReader(unittest.TestCase):
self.assertEqual(sr._path, 'path')
self.assertEqual(sr._body, 'body')
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)
# Check Contentlength raises error if it isn't an integer
@@ -401,10 +401,10 @@ class TestSwiftError(unittest.TestCase):
se = SwiftError(5)
self.assertEqual(se.value, 5)
- self.assertEqual(se.container, None)
- self.assertEqual(se.obj, None)
- self.assertEqual(se.segment, None)
- self.assertEqual(se.exception, None)
+ self.assertIsNone(se.container)
+ self.assertIsNone(se.obj)
+ self.assertIsNone(se.segment)
+ self.assertIsNone(se.exception)
self.assertEqual(str(se), '5')
@@ -526,12 +526,12 @@ class TestSwiftUploadObject(unittest.TestCase):
suo = self.suo('source')
self.assertEqual(suo.source, 'source')
self.assertEqual(suo.object_name, 'source')
- self.assertEqual(suo.options, None)
+ self.assertIsNone(suo.options)
suo = self.suo('source', 'obj_name')
self.assertEqual(suo.source, 'source')
self.assertEqual(suo.object_name, 'obj_name')
- self.assertEqual(suo.options, None)
+ self.assertIsNone(suo.options)
suo = self.suo('source', 'obj_name', {'opt': '123'})
self.assertEqual(suo.source, 'source')
@@ -550,7 +550,7 @@ class TestSwiftUploadObject(unittest.TestCase):
suo = self.suo(mock_file, 'obj_name')
self.assertEqual(suo.source, mock_file)
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'})
self.assertEqual(suo.source, mock_file)
@@ -559,9 +559,9 @@ class TestSwiftUploadObject(unittest.TestCase):
def test_create_with_no_source(self):
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.options, None)
+ self.assertIsNone(suo.options)
# Check error is raised if source is None without an object name
self.assertRaises(SwiftError, self.suo, None)
@@ -1868,7 +1868,7 @@ class TestServiceDownload(_TestServiceBase):
mock_down_cont.assert_not_called()
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):
with mock.patch('swiftclient.service.Connection') as mock_conn: