Replaced assertTrue(False) with fail()

In some unit and functional tests self.assertTrue(False) was used
instead of self.fail(), which might be against readability.

Using assertTrue(False) 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

After replacing assertTrue(False) with fail():

  File "C:\Python361\lib\unittest\case.py", line 666, in fail
    raise self.failureException(msg)
    AssertionError: None

Although the results are the same (both tests failed), the
message 'False is not true' is unnecessary, and can be omitted
from the log by using fail().

Change-Id: I81e21040fd6a2f9713889912fafd2b19bd056b5a
This commit is contained in:
Viktor Varga 2017-06-22 14:37:05 +02:00
parent 3b93fad8d6
commit c4d65601ed
3 changed files with 3 additions and 3 deletions

View File

@ -603,7 +603,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
# if the agent is anything else the test is misconfigured
# we force a test failure with message
else:
self.assertTrue(False, " agent not configured for dvr or dvr_snat")
self.fail("Agent not configured for dvr or dvr_snat")
def _assert_dvr_gateway(self, router):
gateway_expected_in_snat_namespace = (

View File

@ -187,7 +187,7 @@ class ResourceExtensionTest(base.BaseTestCase):
try:
test_app.get("/tweedles/some_id/notimplemented_function")
# Shouldn't be reached
self.assertTrue(False)
self.fail()
except webtest.AppError as e:
self.assertIn('501', str(e))

View File

@ -26,7 +26,7 @@ class TestTesttoolsExceptionHandler(base.BaseTestCase):
def test_exception_handler(self):
try:
self.assertTrue(False)
self.fail()
except Exception:
exc_info = sys.exc_info()
with mock.patch('traceback.print_exception') as mock_print_exception: