From 269f258e1e2935c089d476c5a84ba0b418b1d284 Mon Sep 17 00:00:00 2001 From: Niall Bunting Date: Fri, 12 Aug 2016 11:22:22 +0000 Subject: [PATCH] Add example for diff between assert true and equal On a patch someone said it was not clear to them what the difference was. So I made an example, I thought it may be useful to have this in the docmentation for future reference, for other people. Change-Id: I2825d66ebae5681162e4a868b1083bdbe7f0917a --- .../contributing/minor-code-changes.rst | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/source/contributing/minor-code-changes.rst b/doc/source/contributing/minor-code-changes.rst index be038d648d..751b62ae9e 100644 --- a/doc/source/contributing/minor-code-changes.rst +++ b/doc/source/contributing/minor-code-changes.rst @@ -32,6 +32,29 @@ We're not saying that such changes can never be made, we're just saying that each change must be accompanied by an explanation of why the weaker test is adequate for what's being tested. +Just to make this a bit clearer it can be shown using the following +example, comment out the lines in the runTest method alternatively:: + + import unittest + + class MyTestCase(unittest.TestCase): + def setUp(self): + pass + + class Tests(MyTestCase): + def runTest(self): + self.assertTrue('True') + self.assertTrue(True) + self.assertEqual(True, 'True') + +To run this use:: + + python -m testtools.run test.py + +Also mentioned within the unittests documentation_. + +.. _documentation: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue + LOG.warn to LOG.warning -----------------------