|
| 1 | +=============================== |
| 2 | +Developing with OpenStackClient |
| 3 | +=============================== |
| 4 | + |
| 5 | +Testing |
| 6 | +------- |
| 7 | + |
| 8 | +Using ``tox`` |
| 9 | +============= |
| 10 | + |
| 11 | +Before running tests, you should have ``tox`` installed and available in your |
| 12 | +environment: |
| 13 | + |
| 14 | +.. code-block:: bash |
| 15 | +
|
| 16 | + $ pip install tox |
| 17 | +
|
| 18 | +To execute the full suite of tests maintained within OpenStackClient, run: |
| 19 | + |
| 20 | +.. code-block:: bash |
| 21 | +
|
| 22 | + $ tox |
| 23 | +
|
| 24 | +.. NOTE:: |
| 25 | + |
| 26 | + The first time you run ``tox``, it will take additional time to build |
| 27 | + virtualenvs. You can later use the ``-r`` option with ``tox`` to rebuild |
| 28 | + your virtualenv in a similar manner. |
| 29 | + |
| 30 | +To run tests for one or more specific test environments (for example, the most |
| 31 | +common configuration of Python 2.7 and PEP-8), list the environments with the |
| 32 | +``-e`` option, separated by spaces: |
| 33 | + |
| 34 | +.. code-block:: bash |
| 35 | +
|
| 36 | + $ tox -e py27,pep8 |
| 37 | +
|
| 38 | +See ``tox.ini`` for the full list of available test environments. |
| 39 | + |
| 40 | +Running functional tests |
| 41 | +======================== |
| 42 | + |
| 43 | +OpenStackClient also maintains a set of functional tests that are optimally |
| 44 | +designed to be run against OpenStack's gate. Optionally, a developer may |
| 45 | +choose to run these tests against any OpenStack deployment, however depending |
| 46 | +on the services available, results will vary. |
| 47 | + |
| 48 | +To run the entire suite of functional tests: |
| 49 | + |
| 50 | +.. code-block:: bash |
| 51 | +
|
| 52 | + $ tox -e functional |
| 53 | +
|
| 54 | +To run a specific functional test: |
| 55 | + |
| 56 | +.. code-block:: bash |
| 57 | +
|
| 58 | + $ tox -e functional -- --regex functional.tests.compute.v2.test_server |
| 59 | +
|
| 60 | +Running with PDB |
| 61 | +================ |
| 62 | + |
| 63 | +Using PDB breakpoints with ``tox`` and ``testr`` normally doesn't work since |
| 64 | +the tests fail with a `BdbQuit` exception rather than stopping at the |
| 65 | +breakpoint. |
| 66 | + |
| 67 | +To run with PDB breakpoints during testing, use the `debug` ``tox`` environment |
| 68 | +rather than ``py27``. Here's an example, passing the name of a test since |
| 69 | +you'll normally only want to run the test that hits your breakpoint: |
| 70 | + |
| 71 | +.. code-block:: bash |
| 72 | +
|
| 73 | + $ tox -e debug opentackclient.tests.identity.v3.test_group |
| 74 | +
|
| 75 | +For reference, the `debug` ``tox`` environment implements the instructions |
| 76 | +here: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests |
| 77 | + |
| 78 | + |
| 79 | +Building the Documentation |
| 80 | +-------------------------- |
| 81 | + |
| 82 | +The documentation is generated with Sphinx using the ``tox`` command. To |
| 83 | +create HTML docs, run the following: |
| 84 | + |
| 85 | +.. code-block:: bash |
| 86 | +
|
| 87 | + $ tox -e docs |
| 88 | +
|
| 89 | +The resultant HTML will be the ``doc/build/html`` directory. |
0 commit comments