[openstack-dev] Mock and the stdlib

Robert Collins robertc at robertcollins.net
Thu Feb 11 02:38:46 UTC 2016

We've just had a mass gate breakage due to
https://review.openstack.org/#/c/268945/ go through, so I thought I'd
try to get ahead of anyone trying this again.

unittest.mock in the stdlib is not static, it evolves over time. We're
currently writing to - and depending on - the unittest.mock version
approximately == that in python 3.5. Until we have that as our minimum
python version - no 2.7 - we can't just use 'unittest.mock'.

'mock', the original code that became unittest.mock, is still
maintained. Its a rolling backport of the features that land in
Python's stdlib, which lets us use newer features on older pythons. So
- until the hypothetical date where our minimum Python version is
newer than the oldest capability we need from unittest.mock, we're
going to be using 'mock', not 'unittest.mock'.

-> noone should be importing 'unittest.mock', and 'mock' is the
dependency, not conditional on any given version of Python.

I'm sorry I didn't spot 268945 going through, or I would have -2'd it :(.


Robert Collins <rbtcollins at hpe.com>
Distinguished Technologist
HP Converged Cloud

More information about the OpenStack-dev mailing list