[openstack-dev] H302 considered harmful

Felipe Reyes freyes at tty.cl
Fri Feb 27 19:57:10 UTC 2015


On Wed, 25 Feb 2015 15:47:46 -0500
Doug Hellmann <doug at doughellmann.com> wrote:
> I think the rule originally came from the way mock works. If you
> import a thing in your module and then a test tries to mock where it
> came from, your module still uses the version it imported because the
> name lookup isn't done again at the point when the test runs. If all
> external symbols are accessed through the module that contains them,
> then the lookup is done at runtime instead of import time and mocks
> can replace the symbols. The same benefit would apply to monkey
> patching like what eventlet does, though that's less likely to come
> up in our own code than it is for third-party and stdlib modules.

I strongly agree, when source code does "from module import SomeClass"
is a nightmare patch it at runtime.

Those were my 2 cents to the discussion :)
-- 
Felipe Reyes (GPG:0x9B1FFF39)
http://tty.cl
lp:~freyes | freyes at freenode | freyes at github



More information about the OpenStack-dev mailing list