Replaced assertTrue(False, msg) with fail(msg)
In some unit tests instead of self.fail(msg) statements self.assertTrue(False, msg) were used, which might be ambiguous. Using assertTrue(False, msg) gives the following message on fail: File "C:\Python361\lib\unittest\case.py", line 678, in assertTrue raise self.failureException(msg) AssertionError: False is not true : msg 'False is not true' message implies that unit test failed (as the result is False while we asserted True). Replaced with self.fail(msg) is less ambiguous and more readable. File "C:\Python361\lib\unittest\case.py", line 666, in fail raise self.failureException(msg) AssertionError: msg TrivialFix Change-Id: Ib56a0ed8549fd7af2724eb59222106888781e9c8
This commit is contained in:
parent
3cccd5a0ed
commit
2cb74b1b84
@ -122,7 +122,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertAlmostEqual(exp_timing, timing_call[0][1],
|
||||
places=4)
|
||||
if not found:
|
||||
self.assertTrue(False, 'assertTiming: %s not found in %r' % (
|
||||
self.fail('assertTiming: %s not found in %r' % (
|
||||
exp_metric, timing_calls))
|
||||
|
||||
def assertTimingSince(self, exp_metric, app, exp_start=None):
|
||||
@ -137,7 +137,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertAlmostEqual(exp_start, timing_call[0][1],
|
||||
places=4)
|
||||
if not found:
|
||||
self.assertTrue(False, 'assertTimingSince: %s not found in %r' % (
|
||||
self.fail('assertTimingSince: %s not found in %r' % (
|
||||
exp_metric, timing_calls))
|
||||
|
||||
def assertNotTiming(self, not_exp_metric, app):
|
||||
|
@ -440,8 +440,7 @@ class TestRequest(unittest.TestCase):
|
||||
self.assertEqual("got unexpected keyword argument 'host_url'",
|
||||
str(e))
|
||||
else:
|
||||
self.assertTrue(False, "invalid req_environ_property "
|
||||
"didn't raise error!")
|
||||
self.fail("invalid req_environ_property didn't raise error!")
|
||||
# regular attribute
|
||||
try:
|
||||
swift.common.swob.Request.blank('/', _params_cache={'a': 'b'})
|
||||
@ -449,8 +448,7 @@ class TestRequest(unittest.TestCase):
|
||||
self.assertEqual("got unexpected keyword "
|
||||
"argument '_params_cache'", str(e))
|
||||
else:
|
||||
self.assertTrue(False, "invalid req_environ_property "
|
||||
"didn't raise error!")
|
||||
self.fail("invalid req_environ_property didn't raise error!")
|
||||
# non-existent attribute
|
||||
try:
|
||||
swift.common.swob.Request.blank('/', params_cache={'a': 'b'})
|
||||
@ -458,8 +456,7 @@ class TestRequest(unittest.TestCase):
|
||||
self.assertEqual("got unexpected keyword "
|
||||
"argument 'params_cache'", str(e))
|
||||
else:
|
||||
self.assertTrue(False, "invalid req_environ_property "
|
||||
"didn't raise error!")
|
||||
self.fail("invalid req_environ_property didn't raise error!")
|
||||
# method
|
||||
try:
|
||||
swift.common.swob.Request.blank(
|
||||
@ -468,8 +465,7 @@ class TestRequest(unittest.TestCase):
|
||||
self.assertEqual("got unexpected keyword "
|
||||
"argument 'as_referer'", str(e))
|
||||
else:
|
||||
self.assertTrue(False, "invalid req_environ_property "
|
||||
"didn't raise error!")
|
||||
self.fail("invalid req_environ_property didn't raise error!")
|
||||
|
||||
def test_blank_path_info_precedence(self):
|
||||
blank = swift.common.swob.Request.blank
|
||||
|
Loading…
Reference in New Issue
Block a user