Comment 2 for bug 1511474

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

Yup stub, you're right in that older versions of mock (like v1.0.1) will not surface these errors. That doesn't make it good though :) The issue is that "assert_called_once()" doesn't exist for any version of mock, so we're not testing anything by calling it. The method I believe the test author meant to use was "assert_called_once_with" or, if args aren't needed, assert that the call_count == 1.

What's happening here is that mock 1.0.1 will happily report success for undefined methods. These would both work:

        mock_open_port.show_me_potato_salad()
        mock_open_port.assert_called_once()

In recent mocks, these would throw an AttributeError because the methods don't exist. I think it was v1.3.0 that used autospec=true by default, which is what throws AttrError when you try to mock an undefined method.

Anyway, the purpose of this bug was to point out the futility of using assert_called_once(), but more importantly to call into question the value of [open|close]_port calls during vhost creation. I'm still of the mind that we shouldn't expect these methods to get called during the vhost_create_* tests, and could safely remove those calls/asserts from test_vhost_config_relation.py.