Replace tearDown with addCleanup in magnum unit tests

Bug #1476976 reported by Hua Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Released
Undecided
Hua Wang

Bug Description

Infra team has indicated that tearDown methods should be replaced with addCleanup in unit tests.
The reason is that all addCleanup methods will be executed even if one of them fails, while a failure in tearDown method can leave the rest of the tearDown un-executed, which can leave stale state laying around.

Moreover, tearDown methods won't run if an exception raises in setUp method, while addCleanup will run in such case.

So, we should replace tearDown with addCleanup methods.

Hua Wang (humble00)
Changed in magnum:
assignee: nobody → Hua Wang (humble00)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

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

Changed in magnum:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/204925
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=37af2d70f9f1c2a8454da20c5928bbbe8d1ed9a8
Submitter: Jenkins
Branch: master

commit 37af2d70f9f1c2a8454da20c5928bbbe8d1ed9a8
Author: Hua Wang <email address hidden>
Date: Thu Jul 16 03:03:43 2015 +0800

    Replace tearDown with addCleanup in magnum unit tests

    Infra team has indicated that tearDown methods should be replaced
    with addCleanup in unit tests. The reason is that all addCleanup
    methods will be executed even if one of them fails, while a failure
    in tearDown method can leave the rest of the tearDown un-executed,
    which can leave stale state laying around.

    Moreover, tearDown methods won't run if an exception raises in setUp
    method, while addCleanup will run in such case.

    So, we should replace tearDown with addCleanup methods.

    Change-Id: I3d16954ef7e2fd229f779d193f24ac01d1d2f641
    Closes-Bug: #1476976

Changed in magnum:
status: In Progress → Fix Committed
Adrian Otto (aotto)
Changed in magnum:
milestone: none → mitaka-1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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