<div dir="ltr">Hi I am writing a test for exception . Following is my testing function.<div><pre style="color:rgb(0,0,0);font-family:'Courier New';font-size:9pt">@<span style="color:rgb(0,0,178)">mock.patch</span>(<span style="color:rgb(0,128,0);font-weight:bold">'self.app.post_json'</span>)<br><span style="color:rgb(0,0,128);font-weight:bold">def </span>test_post_exp(<span style="color:rgb(148,85,141)">self</span>, mock_get, mock_http_error_handler):<br><br>    mock_response = mock.Mock()<br>    mock_response.raise_for_status.side_effect = db_exc.DBDuplicateEntry<br>    mock_get.return_value = mock_response<br>    mock_http_error_handler.side_effect = db_exc.DBDuplicateEntry<br>    <span style="color:rgb(0,0,128);font-weight:bold">with </span><span style="color:rgb(148,85,141)">self</span>.assertRaise(db_exc.DBDuplicateEntry):<br>        <span style="color:rgb(148,85,141)">self</span>.app.post_json(<br>            <span style="color:rgb(0,128,0);font-weight:bold">'/v1.0/pods'</span>,<br>            <span style="color:rgb(0,0,128)">dict</span>(<span style="color:rgb(102,0,153)">pod</span>=<span style="color:rgb(0,0,128)">None</span>),<br>            <span style="color:rgb(102,0,153)">expect_errors</span>=<span style="color:rgb(0,0,128)">True</span>)</pre><pre style="color:rgb(0,0,0);font-family:'Courier New';font-size:9pt"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">But when I run tox -epy27 it shows: </span><br></pre><pre style=""><pre style=""><font face="arial, sans-serif"><span style="white-space:normal"> <b> File "/home/khayam/tricircle/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1206, in _importer</b></span></font></pre><pre style=""><font face="arial, sans-serif"><span style="white-space:normal"><b>    thing = __import__(import_path)</b></span></font></pre><pre style=""><font face="arial, sans-serif"><span style="white-space:normal"><b>ImportError: No module named self</b></span></font></pre><pre style=""><font face="arial, sans-serif"><span style="white-space:normal">Can someone guide me whats wrong here. I already had installed latest version of mock, python-dev. </span></font></pre><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br></div></pre><pre style="color:rgb(0,0,0);font-family:'Courier New';font-size:9pt"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"></div></pre></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br></span></div></div>