From c8a00136c2f2e4dcf684c94d5560068ae4dbb3b5 Mon Sep 17 00:00:00 2001 From: Luz <luz.cazares@intel.com> Date: Thu, 18 Feb 2016 16:47:37 -0800 Subject: [PATCH] Documentation tox fix Added information about debugging unit test with tox. Replace 3 references to py26 with py34 to reflect current rally tox configuration. Co-Authored-By: Illia Khudoshyn <ikhudoshyn@mirantis.com> Change-Id: I10c865fae473111b35dca1b9c8f51f31ba066b42 closes-bug: 1547265 --- doc/source/contribute.rst | 34 +++++++++++++++++++++++++++++++--- tox.ini | 9 +++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/doc/source/contribute.rst b/doc/source/contribute.rst index 10fbd892d8..96dbb3e041 100644 --- a/doc/source/contribute.rst +++ b/doc/source/contribute.rst @@ -64,7 +64,7 @@ Several Linux distributions (notably Fedora 16 and Ubuntu 12.04) are also starti 7. Start coding -8. Run the test suite locally to make sure nothing broke, e.g. (this will run py26/py27/pep8 tests): +8. Run the test suite locally to make sure nothing broke, e.g. (this will run py34/py27/pep8 tests): .. code-block:: bash @@ -127,13 +127,41 @@ To run unit tests locally: $ pip install tox $ tox -To run py26, py27 or pep8 only: +To run py34, py27 or pep8 only: .. code-block:: console $ tox -e <name> - #NOTE: <name> is one of py26, py27 or pep8 + #NOTE: <name> is one of py34, py27 or pep8 + +To run a single unit test e.g. test_deployment + +.. code-block:: console + + $ tox -e <name> -- <test_name> + + #NOTE: <name> is one of py34, py27 or pep8 + # <test_name> is the unit test case name + +To debug issues on the unit test: + +- Add breakpoints on the test file using ``import pdb;`` ``pdb.set_trace()`` +- Then run tox in debug mode: + +.. code-block:: console + + $ tox -e debug <test_name> + #NOTE: use python 2.7 + #NOTE: <test_name> is the unit test case name + + or + +.. code-block:: console + + $ tox -e debug34 <test_name> + #NOTE: use python 3.4 + #NOTE: <test_name> is the unit test case name To get test coverage: diff --git a/tox.ini b/tox.ini index a86bff56d7..b7d88c3aaa 100644 --- a/tox.ini +++ b/tox.ini @@ -35,10 +35,19 @@ basepython = python3.4 [testenv:venv] commands = {posargs} + +[testenv:debug] +commands = oslo_debug_helper -t tests {posargs} + +[testenv:debug34] +basepython = python3.4 +commands = oslo_debug_helper -t tests {posargs} + [testenv:cli] sitepackages = True commands = {toxinidir}/tests/ci/rally-integrated.sh + [testenv:cover] commands = {toxinidir}/tests/ci/cover.sh {posargs}