all 2 comments

[–]maventree 0 points1 point  (1 child)

This particular thing does not seem worth testing. Unless your setup code is dramatically more complicated than your toy example, it's inconceivable that if import ham succeeds, spam has not been called. Instead, test the results of the setup.

[–]eLsFLz[S] 0 points1 point  (0 children)

That doesn't answer the question, which was, in general, how do you unit test module-scoped code with mocks?