derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Untested scenario: create_autospec with dynamically provided methods #129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If an object has a __dir__ method and provides some of its attributes 
dynamically, then create_autospec won't find the attribute and will have to 
guess whether or not it should be removing 'self' from the generated signature. 
(So it won't know if a function came from a staticmethod etc)

See the last line (the fallback case effectively) of _must_skip. 

This behaviour is untested / unspecified.

Original issue reported on code.google.com by fuzzyman on 4 Jan 2012 at 5:20

GoogleCodeExporter commented 9 years ago
In practise no skipping should be done - because off an instance the attribute 
should return a bound method (with no self) already, and we probably can't 
fetch the method off the class anyway (__getattr__ won't be invoked). Needs 
testing anyway. (If we can't fetch the attribute from the class but it exists 
in the output of dir(...) then a mock with no spec should probably be used as 
we can't know what the spec should be.) 

Original comment by fuzzyman on 4 Jan 2012 at 6:15