cinder/cinder/tests/unit/targets
Gorka Eguileor 720f07f0d6 Create custom assertTrue and assertFalse
Python's unittest framework assertTrue and assertFalse methods don't
check that the provided value is False or True, like the documentation
says:

  Note that this is equivalent to bool(expr) is True and not to expr is
  True (use assertIs(expr, True) for the latter).

According to the documentation we should try to avoid using it as much
as possible:

  This method should also be avoided when more specific methods are
  available (e.g.  assertEqual(a, b) instead of assertTrue(a == b)),
  because they provide a better error message in case of failure.

But in our current code we keep abusing its use in many ways, among
which we can easily find the following:

- Thinking it only matches False/True

- assertTrue(expected, actual) --> This will always be true as long as
bool(expected) is True, because actual is interpreted as the message to
return on failure.

- Incorrectly testing values, like checking for a tuple of the form
(True, {...}) instead of testing for True in the first position.

This patch fixes incorrect some of the incorrect uses of the methods and
overwrites default methods so that they behave the way many people think
they do:

- assertTrue(x) == assertIs(True,x)
- assertFalse(x) == assertIs(False,x)

This will hopefully help us prevent incorrect usage of the methods.

Change-Id: I1e8c82702932e6b6d940bd83d0a2d4494576a81b
2017-09-11 18:31:20 +02:00
..
__init__.py Move unit tests into dedicated directory 2015-04-21 18:40:40 -06:00
targets_fixture.py LIO: Fix terminate_connection AttributeError 2017-04-27 09:38:12 -04:00
test_base_iscsi_driver.py Create custom assertTrue and assertFalse 2017-09-11 18:31:20 +02:00
test_cxt_driver.py Skip unit-tests which use os.fdatasync on MacOS 2016-10-22 23:55:58 +03:00
test_iet_driver.py Port targets test_iet_driver to Python 3 2015-10-07 17:20:56 +02:00
test_iser_driver.py Remove deprecated ISERTgtAdm 2016-04-11 12:46:44 -05:00
test_lio_driver.py LIO: Fix terminate_connection AttributeError 2017-04-27 09:38:12 -04:00
test_scst_driver.py Targets test refactoring 2015-04-30 18:02:57 +03:00
test_tgt_driver.py Attach/Delete volume for tgt driver race condition fix 2016-12-26 10:15:21 +00:00