faulty way of checking if mock wasn't called

Bug #1368234 reported by Jacek Świderski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Jacek Świderski

Bug Description

Some UT use <mock>.assert_has_calls([]) as a way to check if mock wasn't called - this doesn't work because assert_has_calls only checks if passed calls are present in mock_calls and hence it is always true regardless of whether mock was called or not. This can lead to falsely passed tests.

Changed in neutron:
assignee: nobody → Jacek Świderski (jacek-swiderski)
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/120787

Changed in neutron:
status: New → In Progress
Kyle Mestery (mestery)
Changed in neutron:
milestone: none → juno-rc1
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/120787
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=3b0ac61dea7178e858c6dede44a13818c5162283
Submitter: Jenkins
Branch: master

commit 3b0ac61dea7178e858c6dede44a13818c5162283
Author: Jacek Swiderski <email address hidden>
Date: Thu Sep 11 15:32:18 2014 +0200

    Remove faulty .assert_has_calls([])

    Some UT use <mock>.assert_has_calls([]) as a way to check if mock
    wasn't called - this doesn't work because assert_has_calls only checks
    if passed calls are present in mock_calls and hence it is always true
    regardless of whether mock was called or not. This can lead to falsely
    passed tests.

    Change-Id: I1be5327854cc3dc2f5b3733f2bad78200cfbbfd2
    Closes-Bug: #1368234

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: juno-rc1 → 2014.2
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.