Follow-up on unit testing layered charms

Stuart Bishop stuart.bishop at canonical.com
Thu Sep 1 11:48:22 UTC 2016


On 30 August 2016 at 23:02, Pete Vander Giessen <
pete.vandergiessen at canonical.com> wrote:

The problems with the harness: patching sys.modules leads to a catch-22: if
> we don't leave the mocks in place, we still get import errors when using
> the mock library's mock.patch method, but if we do leave them in place,
> tests that set properties on them can end up interfering with each other.
> There are workarounds, but they're not intuitive, and they don't generate
> friendly error messages when they fail. We felt it best to leave the
> harness behind, and provide some advice on more straightforward things that
> you can do to work around the import errors. Thus the PR referenced above.
>

The tearDown method could reset the mock easily enough. I didn't need to do
that in the simple case I had (a single layer), but it should solve the
test isolation issue you have.



-- 
Stuart Bishop <stuart.bishop at canonical.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20160901/50ade3c9/attachment.html>


More information about the Juju mailing list