qiBuild documentation

Running qiBuild test suite

All in one step

Create a virtualenv to run your tests:

virtualenv venv
source venv/bin/activate

Install qibuild with the “–editable” option, so that your changes are reflected without the need to call pip install again

cd /path/to/qibuild
pip install --editable .

Install all the test dependencies:

cd /path/to/qibuild
pip install -r requirements.txt

Finally, run make:

cd /path/to/qibuild/python
make

This will use pylint to check for obvious errors, then run the full test suite.

Sometimes pylint is mistaken, you can fix this by adding a small comment to disable the check, using the pylint error code:

# pylint:disable-msg=E1101

Running the test suite

This is on a build farm but only for linux and python2.7, so it is possible that some tests will fail.

If you do find a failing test, please open a bug.

If you find a bug, a nice way to make it easier to fix it is to write a failing test and mark it as ‘skipped’

@pytest.skip("See bug # ....")
def test_subtle_bug(self):
   res = do_something_complicated()
   # Should be 42 but for some reason is 41 ...
   assert res == 42

This way when the bug is fixed we just have to remove the @pytest.skip and we are sure the bug never occurs again.

Running only some tests

You can use py.test like this:

  • Just for a given python package:
cd python
py.test qisrc
  • Just for a given test file:
py.test qisrc/test/test_git.py
  • Just for a given test name:
py.test qisrc/test/test_git.py -k set_tracking_branch

Note about debuggers

If you are using ipdb or pdb to insert break points in the code like this:

# in foo.py
def test_my_complicated_function():
    from IPython.core.debugger import Tracer; debug_here=Tracer()
    debug_here()

You will get an error message when you run py.test

The solution is to use the -s option of py.test:

$ py.test foo.py -s

Exiting the virtualenv when you are done

Simply type

$ deactivate

Feel free to remove the virtualenv folder

$ rm -fr venv