title: Mocking an import and some simple attributes
body: <p>I have a package that's imported in my code that I'd like to mock, since I'm developing it in an environment where that package is not available. I get the impression I should be able to do this easily with <code>mock</code>, but have not used it before. In my calling script I put at the top</p>
  
  <pre><code>import sys
  sys.modules['packageneeded'] = mock.MagicMock()
  </code></pre>
  
  <p>and this fixed my downstream errors when importing the package <code>packageneeded</code>. However, I also need to be able to access some attributes downstream, such as <code>packageneeded.__version__</code>. How do I define these attributes in my calling script (or a separate file, if need be).</p>