Add contributor notes on how to use pdb with tests
Change-Id: Ib15a4c06f80dfcfaff2f195ecf0f3afbfb5bfa0b
This commit is contained in:
parent
5419ca908c
commit
ad397b4dd7
@ -211,3 +211,31 @@ Therefore, it is preferable to use:
|
|||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
.. [#f1] See :doc:`jenkins`.
|
.. [#f1] See :doc:`jenkins`.
|
||||||
|
|
||||||
|
|
||||||
|
Debugging
|
||||||
|
---------
|
||||||
|
|
||||||
|
**Debugging unit tests**
|
||||||
|
|
||||||
|
It is possible to attach a debugger to unit tests.
|
||||||
|
|
||||||
|
First, modify the test you want to debug by adding the
|
||||||
|
following to the test code itself:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import pdb
|
||||||
|
pdb.set_trace()
|
||||||
|
|
||||||
|
Then run the unit test with pdb enabled:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
source .tox/py35/bin/activate
|
||||||
|
testr init
|
||||||
|
ostestr --pdb cinder.tests.unit.test_volume_utils
|
||||||
|
# or
|
||||||
|
ostestr -n cinder.tests.unit.test_volume_utils
|
||||||
|
# or
|
||||||
|
ostestr -n cinder/tests/unit/test_context.py
|
||||||
|
Loading…
Reference in New Issue
Block a user