[requirements][all] migration OFF of mock to the unittest.mock built-in library
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library. unittest.mock has been around since python-3.3 so we should not have a problem with python support. This would allow us to drop a library and also help prevent issues with stuff like https://review.opendev.org/712713 is going to expose (nova/neutron fail tests with the external mock-4 library). -- Matthew Thode
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
+1. I started working on this a few weeks ago for nova, and came to the conclusion that it's going to be a multi-step process. This is because step 2 (see below) is going to take a long time and be quite difficult. 1) a) i) Remove mock-the-lib from $project's requirements. ii) Make $project explicitly import unittest.mock everywhere: s/import mock/from unittest import mock/ iii) Handle any weird fallout. You can see i) and ii) for nova here: https://review.opendev.org/#/c/708262/ ...but I likely won't get a chance to work on iii), which would need to happen in the same patch. b) Poison the use of `import mock` e.g. via a hacking rule so it doesn't creep back in. Example in nova: https://review.opendev.org/#/c/708768/ 2) Ferret out and eradicate all transitive dependencies. This is the hard part. That said, if we do 1) everywhere, maybe we don't need to do this. 3) Remove mock-the-lib from the requirements repo. We can't reasonably do this until {every requirements-using repo has done 1)} or {2) has happened}. Thanks, efried .
On Thu, 2020-03-12 at 11:00 -0500, Matthew Thode wrote:
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
yep i have already started doing that in cases where i am intoducing a new unit test file. i have not start chaning over existing usage of the mock lib but im avoiding new usage of it.
unittest.mock has been around since python-3.3 so we should not have a problem with python support. This would allow us to drop a library and also help prevent issues with stuff like https://review.opendev.org/712713 is going to expose (nova/neutron fail tests with the external mock-4 library).
Hi,
On 12 Mar 2020, at 17:00, Matthew Thode <mthode@mthode.org> wrote:
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
It sounds like good candidate for community goal for the next cycle for me :)
unittest.mock has been around since python-3.3 so we should not have a problem with python support. This would allow us to drop a library and also help prevent issues with stuff like https://review.opendev.org/712713 is going to expose (nova/neutron fail tests with the external mock-4 library).
-- Matthew Thode
— Slawek Kaplonski Senior software engineer Red Hat
On Thu, 2020-03-12 at 22:25 +0100, Slawek Kaplonski wrote:
Hi,
On 12 Mar 2020, at 17:00, Matthew Thode <mthode@mthode.org> wrote:
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
It sounds like good candidate for community goal for the next cycle for me :)
Agreed. Matt, can you propose it? Proposing it doesn't mean that it will be selected, nor that you sign up for work, it just makes sure it's available in the pool of goals to select it from. You seem to have a definitive idea, might be worth documenting it! Regards, JP
On 20-03-13 10:00:57, Jean-Philippe Evrard wrote:
On Thu, 2020-03-12 at 22:25 +0100, Slawek Kaplonski wrote:
Hi,
On 12 Mar 2020, at 17:00, Matthew Thode <mthode@mthode.org> wrote:
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
It sounds like good candidate for community goal for the next cycle for me :)
Agreed. Matt, can you propose it? Proposing it doesn't mean that it will be selected, nor that you sign up for work, it just makes sure it's available in the pool of goals to select it from. You seem to have a definitive idea, might be worth documenting it!
Regards, JP
Sure, will add it to todo list for today. -- Matthew Thode
On 20-03-13 10:00:57, Jean-Philippe Evrard wrote:
On Thu, 2020-03-12 at 22:25 +0100, Slawek Kaplonski wrote:
Hi,
On 12 Mar 2020, at 17:00, Matthew Thode <mthode@mthode.org> wrote:
I'd like to suggest, now that we are on modern python, that we stop using the mock library and instead use the built in mock library.
It sounds like good candidate for community goal for the next cycle for me :)
Agreed. Matt, can you propose it? Proposing it doesn't mean that it will be selected, nor that you sign up for work, it just makes sure it's available in the pool of goals to select it from. You seem to have a definitive idea, might be worth documenting it!
Regards, JP
https://etherpad.openstack.org/p/community-goals seemed like the right first place to put it, so that's where it goes (at the bottom). -- Matthew Thode
participants (5)
-
Eric Fried
-
Jean-Philippe Evrard
-
Matthew Thode
-
Sean Mooney
-
Slawek Kaplonski