[openstack-dev] [Tricircle] Error runnig py27

joehuang joehuang at huawei.com
Thu Apr 14 00:53:49 UTC 2016


Hi, Khayam,

@mock.patch('self.app.post_json')

No “self.” needed.

Best Regards
Chaoyi Huang ( Joe Huang )

From: Khayam Gondal [mailto:khayam.gondal at gmail.com]
Sent: Wednesday, April 13, 2016 2:50 PM
To: OpenStack Development Mailing List (not for usage questions)
Cc: joehuang; Zhiyuan Cai
Subject: [Tricircle] Error runnig py27

Hi I am writing a test for exception . Following is my testing function.

@mock.patch('self.app.post_json')
def test_post_exp(self, mock_get, mock_http_error_handler):

    mock_response = mock.Mock()
    mock_response.raise_for_status.side_effect = db_exc.DBDuplicateEntry
    mock_get.return_value = mock_response
    mock_http_error_handler.side_effect = db_exc.DBDuplicateEntry
    with self.assertRaise(db_exc.DBDuplicateEntry):
        self.app.post_json(
            '/v1.0/pods',
            dict(pod=None),
            expect_errors=True)

But when I run tox -epy27 it shows:

  File "/home/khayam/tricircle/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1206, in _importer

    thing = __import__(import_path)

ImportError: No module named self

Can someone guide me whats wrong here. I already had installed latest version of mock, python-dev.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160414/1c1db770/attachment.html>


More information about the OpenStack-dev mailing list