| 1 |
.. _existingtestsuite: |
| 2 |
|
| 3 |
How to use pytest with an existing test suite |
| 4 |
============================================== |
| 5 |
|
| 6 |
Pytest can be used with most existing test suites, but its |
| 7 |
behavior differs from other test runners such as Python's |
| 8 |
default unittest framework. |
| 9 |
|
| 10 |
Before using this section you will want to :ref:`install pytest <getstarted>`. |
| 11 |
|
| 12 |
Running an existing test suite with pytest |
| 13 |
--------------------------------------------- |
| 14 |
|
| 15 |
Say you want to contribute to an existing repository somewhere. |
| 16 |
After pulling the code into your development space using some |
| 17 |
flavor of version control and (optionally) setting up a virtualenv |
| 18 |
you will want to run: |
| 19 |
|
| 20 |
.. code-block:: bash |
| 21 |
|
| 22 |
cd <repository> |
| 23 |
pip install -e . # Environment dependent alternatives include |
| 24 |
# 'python setup.py develop' and 'conda develop' |
| 25 |
|
| 26 |
in your project root. This will set up a symlink to your code in |
| 27 |
site-packages, allowing you to edit your code while your tests |
| 28 |
run against it as if it were installed. |
| 29 |
|
| 30 |
Setting up your project in development mode lets you avoid having to |
| 31 |
reinstall every time you want to run your tests, and is less brittle than |
| 32 |
mucking about with sys.path to point your tests at local code. |
| 33 |
|
| 34 |
Also consider using :ref:`tox <use tox>`. |