title: Assert Error is thrown when mocking python3
body: <p>I am trying to write a test that mocks raising <code>PermissionError</code> on a call to <code>open()</code> when attempting to open a file for reading. However I cannot seem to get the test working. The <code>PermissionError</code> appears to be thrown but my test fails because of this even though I am trying to assert it is thrown. </p>
  
  <p>Below contains one of my attempts:</p>
  
  <p><strong>fileMethods.py</strong></p>
  
  <pre><code>def readfile(myfile):
      with open(myfile, 'r') as file:
          filecontent = file.read()
      file.close()
      return filecontent
  </code></pre>
  
  <p><strong>fileMethods_test.py</strong></p>
  
  <pre><code>def test_readfile_throws_PermissionError(self):
      with mock.patch('fileMethods.open') as openMock:
          openMock.side_effect = PermissionError
          self.assertRaises(PermissionError, fileMethods.readfile('file_to_readin'))
  </code></pre>
  
  <p>Am I missing something obvious or is the way I am testing this method incorrect?</p>