From cf68b457bcf98e3995cc3d81a98a4eee54b59fbf Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Tue, 20 Sep 2016 17:01:48 +0530 Subject: [PATCH] Add support to use pdb with tox Change-Id: Id1b208843ab038a38f389097baafe985d5ea92e9 --- README.rst | 20 +++++++++++++++++++- test-requirements.txt | 1 + tox.ini | 5 ++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 638eef64c..0e68dd034 100644 --- a/README.rst +++ b/README.rst @@ -296,7 +296,25 @@ Read the HTML documentation Open doc/html/index.html in a browser -4.3 Upgrade +4.3 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.TestClass.test_name + +For more information see the `oslotest documentation +`_. + +4.4 Upgrade ----------- Here are the instructions for upgrading to a new release of the diff --git a/test-requirements.txt b/test-requirements.txt index fae3138a9..1eee77370 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,6 +7,7 @@ coverage>=3.6 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD mock>=2.0 # BSD mox3>=0.7.0 # Apache-2.0 +oslotest>=1.10.0 # Apache-2.0 requests-mock>=1.0 # Apache-2.0 python-subunit>=0.0.18 # Apache-2.0/BSD testrepository>=0.0.18 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index bc73c35f8..c80f6d8d6 100644 --- a/tox.ini +++ b/tox.ini @@ -31,6 +31,9 @@ commands = {posargs} [testenv:cover] commands = python setup.py testr --coverage --testr-args='{posargs}' +[testenv:debug] +commands = oslo_debug_helper -t congress/tests {posargs} + [testenv:bench] setenv = TEST_BENCHMARK=true @@ -56,4 +59,4 @@ setenv = PYTHONHASHSEED=0 commands = python setup.py build_sphinx [testenv:releasenotes] -commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html \ No newline at end of file +commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html