Python3: patch_mock_module not patching unittest.mock

Bug #1882107 reported by Gorka Eguileor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslotest
New
Undecided
Unassigned

Bug Description

When running in Python 3, method "patch_mock_module" in "mock_fixture" does not patch "unittest.mock" and only patches the "mock" module, so we end up having the "autospec" issues described in https://docs.openstack.org/oslotest/latest/user/mock-autospec.html if new tests start using "unittest.mock".

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

I think this is addressed by https://review.opendev.org/#/c/717311/

oslotest was switched over to unittest.mock in ussuri, but there were unintended side effects from that since we found many projects were using the third party mock module, but not declaring it in their own test-requirements. They were depending on it being present by being pulled in by the oslotest install.

Since it was late in the cycle, the switch in oslotest from mock to unittest.mock was reverted. Now that we are into victoria, this should be done again and any projects that break should be updated to either explicitly declare their dependency on mock, or ideally, update their mocking usage to use the unittest.mock module.

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.