From 7abfe286186269e5a2f0bd79997756897c146613 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Fri, 3 Jun 2016 10:21:33 +0100 Subject: [PATCH] Add debug environment to tox The oslo_debug_helper enables developers to use pdb for debugging the unittests. Ref: http://docs.openstack.org/developer/oslotest/features.html Change-Id: I08d4c0fcb2e8015c02f5e9b9d4e9dff7f58d21ea --- doc/source/dev/dev-quickstart.rst | 20 ++++++++++++++++++++ tox.ini | 3 +++ 2 files changed, 23 insertions(+) diff --git a/doc/source/dev/dev-quickstart.rst b/doc/source/dev/dev-quickstart.rst index 4c902a2e8d..ec65245ecf 100644 --- a/doc/source/dev/dev-quickstart.rst +++ b/doc/source/dev/dev-quickstart.rst @@ -116,6 +116,26 @@ To run only the pep8/flake8 syntax and style checks:: tox -epep8 +Debugging unit tests +-------------------- + +In order to break into the debugger from a unit test we need to insert +a breaking point to the code: + +.. code-block:: python + + import pdb; pdb.set_trace() + +Then run ``tox`` with the debug environment as one of the following:: + + tox -e debug + tox -e debug test_file_name + tox -e debug test_file_name.TestClass + tox -e debug test_file_name.TestClass.test_name + +For more information see the `oslotest documentation +`_. + =============================== Exercising the Services Locally =============================== diff --git a/tox.ini b/tox.ini index 6339ffeb53..beb8a7182b 100644 --- a/tox.ini +++ b/tox.ini @@ -58,6 +58,9 @@ envdir = {toxworkdir}/venv commands = oslo-config-generator --config-file=tools/config/ironic-config-generator.conf +[testenv:debug] +commands = oslo_debug_helper -t ironic/tests/unit {posargs} + [testenv:docs] setenv = PYTHONHASHSEED=0 sitepackages = False