[TIP] patch automatically functions in external library

Jens Rantil jens.rantil at gmail.com
Tue Aug 21 14:58:52 PDT 2012


Hi Andrea,

Since you seem to have receive any response at all I'll pitch in my 5 cents;

First off, pep8 states that "private" functions should be prepended with an
underscore. Using this style could make things like this much simpler - you
would only have to worry about public functions. But maybe you already do
this...

That said, depending on Python version you are targetting you could use
importlib[1,2] to create your own module importer that wraps the real
module using Mock <http://www.voidspace.org.uk/python/mock/>, or similar.

[1] http://pypi.python.org/pypi/importlib/
[2] http://docs.python.org/dev/library/importlib.html

Cheers,
Jens

On Mon, Aug 20, 2012 at 5:18 PM, andrea crotti <andrea.crotti.0 at gmail.com>wrote:

> I have one "common" project that contains a lot of code which is useful
> from more different projects.
>
> All projects have (hopefully) unit tests, but what I'm worried about now
> is that changing a function signature in *common* might make break
> something somewhere else.
>
> This is a common problem I guess, and I could use something like pylint
> maybe..
>
> But even better, if I'm able to
> - automatically mock every "common" import, using as a spec the real one
> - check that every function call has the right arguments
>
> it would be even better I think..
> Is that possible or is there another better way?
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



-- 
Want to know how full my inbox is? Or how to get in touch with me faster?
Or tell me your e-mail is not that important? Then check this out:
http://courteous.ly/4WtfZY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20120821/1ca7e892/attachment.htm>


More information about the testing-in-python mailing list