Misuse of assertTrue in test scripts

Bug #1221517 reported by Zhongyue Luo on 2013-09-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Low
Zhongyue Luo

Bug Description

cinder/tests/brick/test_brick_connector.py
- self.assertTrue(obj.__class__.__name__,
- "ISCSIConnector")

- self.assertTrue(obj.__class__.__name__,
- "FibreChannelConnector")

- self.assertTrue(obj.__class__.__name__,
- "AoEConnector")

- self.assertTrue(obj.__class__.__name__,
- "RemoteFsConnector")

- self.assertTrue(obj.__class__.__name__,
- "RemoteFsConnector")

cinder/tests/brick/test_brick_linuxscsi.py
- self.assertTrue(name, device_name)

All assertTrue should be assertEqual

Zhongyue Luo (zyluo) on 2013-09-06
Changed in cinder:
assignee: nobody → Zhongyue Luo (zyluo)

Fix proposed to branch: master
Review: https://review.openstack.org/45370

Changed in cinder:
status: New → In Progress
Eric Harney (eharney) on 2013-09-06
Changed in cinder:
importance: Undecided → Low

Reviewed: https://review.openstack.org/45370
Committed: http://github.com/openstack/cinder/commit/b2e0f75ddaea0c12e154432da7a860725af8e344
Submitter: Jenkins
Branch: master

commit b2e0f75ddaea0c12e154432da7a860725af8e344
Author: Zhongyue Luo <email address hidden>
Date: Fri Sep 6 12:10:28 2013 +0800

    Fixes misuse of assertTrue in test scripts

    Misuse of assertTrue in places where assertEqual should be used.

    If assertTrue is used instead of assertEquals, the test will always pass
    if the first argument's boolean cast is True. The second argument
    passed to assertTrue() will be regarded as the error message
    when the assertion fails. Using assertEqual will actually check
    if two arguments are same value.

    Fixes bug #1221517

    Change-Id: I68f614164803729ea26e65f8868b0031e724d324

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2013-10-04
Changed in cinder:
milestone: none → havana-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2013-10-17
Changed in cinder:
milestone: havana-rc1 → 2013.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers