Custom Search

Thursday, December 4, 2014

OpenStack Debug Python Unit Test using pdb

1)
Add following statements in Unit Test Code where you want to debug

import pdb
pdb.set_trace()




2)
Run "run_tests.sh" with "--debug" option

#./run_tests.sh --debug neutron.tests.unit.opencontrail.test_extension_ipam.IpamExtensionTestCase.test_create_ipam

OR

Run the test with "testtools" instead of "testr"

a)
If you are using "run_tests.sh" environment
#source .venv/bin/activate
#.venv/bin/python -m testtools.run neutron.tests.unit.opencontrail.test_extension_ipam.IpamExtensionTestCase.test_create_ipam

b)
If you are using "Tox" environment
#source .tox/py27/bin/activate
#.tox/py27/bin/python -m testtools.run neutron.tests.unit.opencontrail.test_extension_ipam.IpamExtensionTestCase.test_create_ipam


2 comments:

  1. I did some changing in neutron code, How can I re-run devstack so that these changes can be visible in devstack

    ReplyDelete
    Replies
    1. "./unstack.sh" then "./clean.sh". After that you can re-run devstack again "./stack.sh".

      Delete