Hello, Khayam,

You can write the test case for the exception like : 
http://paste.openstack.org/show/494530/

Best Regards
Chaoyi Huang ( Joe Huang )

From: Khayam Gondal [mailto:khayam.gon...@gmail.com]
Sent: Monday, April 18, 2016 8:22 PM
To: joehuang
Cc: OpenStack Development Mailing List (not for usage questions); Zhiyuan Cai
Subject: Re: [Tricircle] Error runnig py27

Sorry, email went to spam. Just saw it.
Following is link
http://paste.openstack.org/show/494403/

On Mon, Apr 18, 2016 at 8:41 AM, joehuang 
<joehu...@huawei.com<mailto:joehu...@huawei.com>> wrote:
Hi, Khayam,

Could you paste your whole file for test cases and the source code to be tested 
in the http://paste.openstack.org/ seperatly.

Please share the links, so that to find out what happened.

Best Regards
Chaoyi Huang ( Joe Huang )

From: Khayam Gondal 
[mailto:khayam.gon...@gmail.com<mailto:khayam.gon...@gmail.com>]
Sent: Thursday, April 14, 2016 5:30 PM
To: joehuang
Cc: OpenStack Development Mailing List (not for usage questions); Zhiyuan Cai
Subject: Re: [Tricircle] Error runnig py27

Hi joehuang,
by removing self it is showing following error.

  File 
"/home/khayam/tricircle/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py",
 line 1206, in _importer
    thing = __import __ (import_path)
Import Error: No module named app
Ran 135 tests in 2.994s (+ 0.940s)


On Thu, Apr 14, 2016 at 5:53 AM, joehuang 
<joehu...@huawei.com<mailto:joehu...@huawei.com>> wrote:
Hi, Khayam,

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

No “self.” needed.

Best Regards
Chaoyi Huang ( Joe Huang )

From: Khayam Gondal 
[mailto:khayam.gon...@gmail.com<mailto:khayam.gon...@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.





__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to