Search in this blog

Tuesday, December 27, 2016

Run a single python test with tox

This is the hint how to run a single or several specific functional and unit tests in python projects with tox.

Tox environment `functional`:

Run tests by the template of their name:
tox -e functional test_node_list

Run single test specifying full path:
tox -e ironicclient.tests.functional.osc.v1.test_baremetal_node_basic.BaremetalNodeTests.test_list

Run class of tests:
tox -e functional BaremetalNodeTests

Run specific test from class (including those under @ddt):
tox -e functional BaremetalNodeTests.test_delete

Unit tests (py27 for example):

Run several matching tests:
tox -e py27 do_port_show

Run single specific test from specified class:
tox -e py27 PortShellTest.test_do_port_show_invalid_fields

How to resolve a merge conflict?

How to resolve Git merge conflict in workflow using Gerrit?

Example

1. Clone the project Git repository
git clone https://github.com/openstack/python-ironicclient.git
cd python-ironicclient/

2. Create a new local branch for the issue you are working on
git checkout -b bug/1566329

3. Cherry-pick your patch set from Gerrit
git fetch https://git.openstack.org/openstack/python-ironicclient refs/changes/92/365692/11 && git cherry-pick FETCH_HEAD

4. Check git status to see where conflict is
git status

5. Resolve merge conflict using merge tool, IDE or text editor

6. Add changes to the next commit
git add ironicclient/tests/functional/osc/v1/base.py

7. Continue cherry-pick operation
git cherry-pick --continue

8. Push it back to Gerrit
git review