title: Python's mock throwing AttributeError: 'module' object has no attribute 'patch'
body: <p>I am trying to create some tests for a Python program.  I am using Python version 2.7.12 so I had to install <code>mock</code> using <code>sudo pip install mock</code>.</p>
  
  <p>According to the <a href="https://docs.python.org/3/library/unittest.mock.html#quick-guide" rel="noreferrer">documentation</a> and <a href="https://blog.fugue.co/2016-02-11-python-mocking-101.html" rel="noreferrer">several</a> <a href="https://www.toptal.com/python/an-introduction-to-mocking-in-python" rel="noreferrer">other</a> <a href="https://stackoverflow.com/questions/20242862/why-python-mock-patch-doesnt-work">sites</a>, I should be able to use the following code to use patch:</p>
  
  <pre><code>import mock     # Also could use from mock import patch
  import unittest
  
  class TestCases(unittest.TestCase):
      @mock.patch('MyClass.ImportedClass')   # If using from mock import patch should just be @patch
      def test_patches(self, mock_ImportedClass):
          # Test code...
  </code></pre>
  
  <p>However, the above code throws the following error:</p>
  
  <pre><code>AttributeError: 'module' object has no attribute 'patch'
  </code></pre>
  
  <p>After some experimenting in the terminal, it seems quite a few things don't work.  For example</p>
  
  <pre><code>&gt;&gt;&gt; import mock
  
  &gt;&gt;&gt; mock.MagicMock
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: 'module' object has no attribute 'MagicMock'
  
  &gt;&gt;&gt; mock.patch
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: 'module' object has no attribute 'patch'
  
  &gt;&gt;&gt; mock.Mock
  &lt;class mock.Mock at 0x7fdff56b0600&gt;
  </code></pre>
  
  <p>Interestingly, I can access something called <code>patch</code> using <code>mock.Mock()</code>, but I don't know if this works in the same way and cannot find anything about it in the documentation.</p>
  
  <p>My experience with Python is fairly limited so I'm not sure what might be wrong.  I'm fairly certain the right package was installed.  Any help on how I can get this working?</p>