2017-04-07 10:29:41 +08:00
|
|
|
.. _existingtestsuite:
|
|
|
|
|
2021-03-11 03:18:21 +08:00
|
|
|
How to use pytest with an existing test suite
|
|
|
|
==============================================
|
2016-09-28 03:51:46 +08:00
|
|
|
|
2017-04-07 10:29:41 +08:00
|
|
|
Pytest can be used with most existing test suites, but its
|
2024-01-01 21:20:38 +08:00
|
|
|
behavior differs from other test runners such as Python's
|
|
|
|
default unittest framework.
|
2016-09-28 03:51:46 +08:00
|
|
|
|
2017-04-07 10:29:41 +08:00
|
|
|
Before using this section you will want to :ref:`install pytest <getstarted>`.
|
2016-09-28 03:51:46 +08:00
|
|
|
|
|
|
|
Running an existing test suite with pytest
|
|
|
|
---------------------------------------------
|
|
|
|
|
2017-04-07 10:29:41 +08:00
|
|
|
Say you want to contribute to an existing repository somewhere.
|
|
|
|
After pulling the code into your development space using some
|
2016-09-28 03:51:46 +08:00
|
|
|
flavor of version control and (optionally) setting up a virtualenv
|
2019-08-07 07:20:06 +08:00
|
|
|
you will want to run:
|
2017-04-07 10:29:41 +08:00
|
|
|
|
2019-08-07 04:25:54 +08:00
|
|
|
.. code-block:: bash
|
|
|
|
|
2016-09-28 03:51:46 +08:00
|
|
|
cd <repository>
|
2017-04-07 10:29:41 +08:00
|
|
|
pip install -e . # Environment dependent alternatives include
|
|
|
|
# 'python setup.py develop' and 'conda develop'
|
2016-09-28 03:51:46 +08:00
|
|
|
|
|
|
|
in your project root. This will set up a symlink to your code in
|
|
|
|
site-packages, allowing you to edit your code while your tests
|
|
|
|
run against it as if it were installed.
|
|
|
|
|
2017-04-07 10:29:41 +08:00
|
|
|
Setting up your project in development mode lets you avoid having to
|
|
|
|
reinstall every time you want to run your tests, and is less brittle than
|
2016-09-28 03:51:46 +08:00
|
|
|
mucking about with sys.path to point your tests at local code.
|
|
|
|
|
2017-04-07 10:29:41 +08:00
|
|
|
Also consider using :ref:`tox <use tox>`.
|