Files
deb-python-oslotest/doc/source/features.rst
Steve Martinelli e5c14b74d3 Add an extra parameter for test directory in debugger script
The `python-*client`'s usually give back the full package name
i.e. python-keystoneclient, and the script assumes thats where
the tests are, but most clients have their tests under just
*client, or in this case keystoneclient.
Oslo projects have a similar issue.
Change the debug script to accept an optional argument that can
be used to override the guesstimated value.

Change-Id: If0a25ae7ab9f854f87271a377dd228e2ebfb107f
2014-09-29 21:50:41 -04:00

1.4 KiB

Features

Debugging with oslo_debug_helper.sh

The oslotest package also distributes a shell file that may be used to assist in debugging python code. The shell file uses testtools, and supports debugging with pdb.

Adding breakpoints to the code

The typical usage to break into the debugger from a running program is to insert:

import pdb; pdb.set_trace()

Update tox.ini

Within the tox.ini file of your project add the following:

[testenv:debug]
commands = oslo_debug_helper {posargs}

If the project name, and the module that precedes the tests directory do not match, then consider passing an argument to tox.ini.

For example, python-keystoneclient project has tests in keystoneclient/tests, thus it would have to pass in:

[testenv:debug]
commands = oslo_debug_helper -t keystoneclient/tests {posargs}

Similarily, most oslo projects have the tests at the package level, it would have to pass in:

[testenv:debug]
commands = oslo_debug_helper -t tests {posargs}

To run with tox:

$ tox -e debug
$ tox -e debug test_notifications
$ tox -e debug test_notifications.NotificationsTestCase
$ tox -e debug test_notifications.NotificationsTestCase.test_send_notification