Replace mock.assert_not_called() with self.assertFalse(mock.called) in unit tests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic |
Fix Released
|
Medium
|
Max Lobur |
Bug Description
There is no assert_not_called method in mock object.
Here are some debug outs:
(Pdb) perform_mock
<MagicMock name='_
(Pdb) dir(perform_mock)
['assert_any_call', 'assert_
(Pdb) perform_
<MagicMock name='_
Since this is mock, it mocks all it's interface (using __getattr__) and returns the new mock as a result of any non-existent method call or non-existent property read. Need to be careful with this.
Currently I found the only usage of non-existent "assert_not_called" here:
https:/
But there may be others, like a "assert_not_called" with some typo, which will work the same way...
This should be replaced with
self.assertFals
Related topic http://
description: | updated |
summary: |
- Replace mock.assert_not_called() to - self.assertFalse(perform_mock.called) in unit tests + Replace mock.assert_not_called() to self.assertFalse(mock.called) in + unit tests |
summary: |
- Replace mock.assert_not_called() to self.assertFalse(mock.called) in + Replace mock.assert_not_called() with self.assertFalse(mock.called) in unit tests |
Changed in ironic: | |
milestone: | none → icehouse-3 |
status: | Fix Committed → Fix Released |
Changed in ironic: | |
milestone: | icehouse-3 → 2014.1 |
I also grep'd for assert_ was_not_ called, assert_has_no_calls - no occurrences found. Seems the one mentioned above is the only