title: How to exclude mock package from python coverage report using nosetests
body: <p>I currently try to use the mock library to write some basic nose unittests in python.</p>
  
  <p>After finishing some basic example I now tried to use <code>nosetests --with-coverage</code> and now I have the mock package and the package I tried to 'mock away' are shown in the coverage report. Is there a possibility to exclude these?</p>
  
  <p>Here is the class I want to test:</p>
  
  <pre><code>from imaplib import IMAP4
  
  class ImapProxy:
      def __init__(self, host):
          self._client = IMAP4(host)
  </code></pre>
  
  <p>And the testcase:
      from mock import patch</p>
  
  <pre><code>from ImapProxy import ImapProxy
  
  class TestImap:
      def test_connect(self):
          with patch('ImapProxy.IMAP4') as imapMock:
              proxy = ImapProxy("testhost")
              imapMock.assert_called_once_with("testhost")
  </code></pre>
  
  <p>I now get the following output for <code>nosetests --with-coverage</code></p>
  
  <pre><code>.
  Name         Stmts   Miss  Cover   Missing
  ------------------------------------------
  ImapProxy        4      0   100%   
  imaplib        675    675     0%   23-1519
  mock          1240    810    35%   [ a lot of lines]
  </code></pre>
  
  <p>Is there any way to exclude the mock package and the imaplib package <strong>without</strong> having to manually whitelisting all but those packages by <code>--cover-package=PACKAGE</code></p>
  
  <p>Thanks to Ned Batchelder I now know about the .coveragerc file, thanks for that!</p>
  
  <p>I created a .coveragerc file with the following content:</p>
  
  <pre><code>[report]
  omit = *mock*
  </code></pre>
  
  <p>Now my output for mock in the coverage report is:</p>
  
  <pre><code>mock                     1240   1240     0%   16-2356
  </code></pre>
  
  <p>It does not cover the mock package any longer but still shows it in the report.</p>
  
  <p>I use Coverage.py, version 3.5.2 if this is any help.</p>