On 3 March 2014 17:49, Nate Finch nate.fi...@canonical.com wrote:
John talked to me on a hangout and suggested that, often times, when you
need to expose something like this for tests, it ends up being something
that production code needs to tweak as well. He'd like to see something
better
This is kind of why I made MockPackage, one of those if there's something
you don't want people to use, make it ugly.
If you really want to expose a knob, it's either a public variable or
get/set functions. I don't know of a third way. The nice thing about
get/set is that it at least sort
of these variables that it was not supposed to be using.
The fix I thought up was to instead make a function called MockPackage().
This function does everything that is needed to mock out the package for
testing, and returns a function that undoes the mocking.
The reason I like this better
called MockPackage().
This function does everything that is needed to mock out the package for
testing, and returns a function that undoes the mocking.
The reason I like this better that public variables is twofold:
1.) It's a lot more obvious that MockPackage is something that you
shouldn't