assertTrue format incorrect in test_extensions.py unit test

Bug #1218713 reported by Rajdeep
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Cedric Brandily

Bug Description

Usage of assertTrue/assertFalse needs modification in the unit tests
Change example

from assertTrue(x in y) => assertIn(x,y)
assertFalse(x in y) => assertNotIn(x, y)

Applicable to all the unit test cases

Reference : Similar bug https://bugs.launchpad.net/neutron/+bug/1217028

Rajdeep (dua-rajdeep)
description: updated
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
assignee: nobody → Rajdeep (dua-rajdeep)
status: New → In Progress
Rajdeep (dua-rajdeep)
description: updated
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

i mark bug/1218706 and bug/1218671 duplicate to this

please fix the assertFalse in the same time

tags: added: unittest
description: updated
Rajdeep (dua-rajdeep)
description: updated
Revision history for this message
Rajdeep (dua-rajdeep) wrote :

Uploaded the patch waiting for review

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in neutron:
assignee: Rajdeep (dua-rajdeep) → Cedric Brandily (cbrandily)
Changed in neutron:
assignee: Cedric Brandily (cbrandily) → Armando Migliaccio (armando-migliaccio)
Changed in neutron:
assignee: Armando Migliaccio (armando-migliaccio) → Cedric Brandily (cbrandily)
importance: Undecided → Low
tags: added: low-hanging-fruit
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/230823
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=49746ca4749c45d2772289061f161145eb5ad2b8
Submitter: Jenkins
Branch: master

commit 49746ca4749c45d2772289061f161145eb5ad2b8
Author: Cedric Brandily <email address hidden>
Date: Sun Oct 4 20:48:44 2015 +0200

    Use assertIn and assertNotIn

    Neutron tests should use:

      self.assertIn(value, list)
      self.assertNotIn(value, list)

    instead of:

      self.assertTrue(value in list)
      self.assertFalse(value in list)

    because assertIn and assertNotIn raise more meaningful errors:

      self.assertIn(3, [1, 2]
      >>> MismatchError: 3 not in [1, 2]

      self.assertTrue(3 in [1, 2])
      >>> AssertionError: False is not true

    Closes-Bug: #1218713

    Change-Id: Ic8492a88935bf005feb9dae726a4bee604a8bd09

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron-fwaas (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/231286

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron-lbaas (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/232292

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/233167

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron-lbaas (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron-lbaas (master)

Change abandoned by Bertrand Lallau (<email address hidden>) on branch: master
Review: https://review.openstack.org/236846

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron-fwaas (master)

Reviewed: https://review.openstack.org/231286
Committed: https://git.openstack.org/cgit/openstack/neutron-fwaas/commit/?id=5687a4af599172970c8b90d6a27c3a9b20b00ff5
Submitter: Jenkins
Branch: master

commit 5687a4af599172970c8b90d6a27c3a9b20b00ff5
Author: Reedip Banerjee <email address hidden>
Date: Tue Oct 6 07:01:43 2015 +0530

    Use assert(Not)In instead of assertTrue/False

    Neutron tests should use:

    self.assertIn(value, list) and
    self.assertNotIn(value, list)

    instead of:

    self.assertTrue(value in list) and
    self.assertFalse(value in list)

    because assertIn and assertNotIn raise more meaningful errors:

    self.assertIn(3, [1, 2])
    >>> MismatchError: 3 not in [1, 2]

    self.assertTrue(3 in [1, 2])
    >>> AssertionError: False is not true

    To enforce this improvement, this patch is created.

    Change-Id: Ia2ca003829858cceda181da41dea4f70a3d48d45
    Related-Bug: #1218713

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron-lbaas (master)

Reviewed: https://review.openstack.org/232292
Committed: https://git.openstack.org/cgit/openstack/neutron-lbaas/commit/?id=67b7d925838739642a61c65094faf73ca338208f
Submitter: Jenkins
Branch: master

commit 67b7d925838739642a61c65094faf73ca338208f
Author: Kenji Yasui <email address hidden>
Date: Wed Oct 7 07:34:37 2015 +0000

    Use assert(Not)In instead of assertTrue/False

    Neutron tests should use:

    self.assertIn(value, list) and
    self.assertNotIn(value, list)

    instead of:

    self.assertTrue(value in list) and
    self.assertFalse(value in list)

    because assertIn and assertNotIn raise more meaningful errors:

    self.assertIn(3, [1, 2])
    >>> MismatchError: 3 not in [1, 2]

    self.assertTrue(3 in [1, 2])
    >>> AssertionError: False is not true

    To enforce this improvement, this patch is created.

    Change-Id: I4a05ad5a5ff9674dd94cff8b11585fd39dc264b3
    Related-Bug: #1218713

Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/neutron 8.0.0.0b1

This issue was fixed in the openstack/neutron 8.0.0.0b1 development milestone.

Changed in neutron:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (master)

Change abandoned by Armando Migliaccio (<email address hidden>) on branch: master
Review: https://review.openstack.org/233167
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.