Fix links in docs

This commit is contained in:
Bruno Oliveira 2017-04-06 23:29:41 -03:00
parent 45852386e5
commit f2300fbab2
2 changed files with 25 additions and 23 deletions

View File

@ -1,32 +1,34 @@
.. _existingtestsuite:
Using pytest with an existing test suite Using pytest with an existing test suite
=========================================== ===========================================
Pytest can be used with most existing test suites, but its Pytest can be used with most existing test suites, but its
behavior differs from other test runners such as :ref:`nose` or behavior differs from other test runners such as :ref:`nose <noseintegration>` or
Python's default unittest framework. Python's default unittest framework.
Before using this section you will want to :ref:`getting-started <install pytest>`. Before using this section you will want to :ref:`install pytest <getstarted>`.
Running an existing test suite with pytest Running an existing test suite with pytest
--------------------------------------------- ---------------------------------------------
Say you want to contribute to an existing repository somewhere. Say you want to contribute to an existing repository somewhere.
After pulling the code into your development space using some After pulling the code into your development space using some
flavor of version control and (optionally) setting up a virtualenv flavor of version control and (optionally) setting up a virtualenv
you will want to run:: you will want to run::
cd <repository> cd <repository>
pip install -e . # Environment dependent alternatives include pip install -e . # Environment dependent alternatives include
# 'python setup.py develop' and 'conda develop' # 'python setup.py develop' and 'conda develop'
in your project root. This will set up a symlink to your code in 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 site-packages, allowing you to edit your code while your tests
run against it as if it were installed. run against it as if it were installed.
Setting up your project in development mode lets you avoid having to 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 reinstall every time you want to run your tests, and is less brittle than
mucking about with sys.path to point your tests at local code. mucking about with sys.path to point your tests at local code.
Also consider using `Tox <https://tox.readthedocs.io/en/latest>`_. Also consider using :ref:`tox <use tox>`.
.. include:: links.inc .. include:: links.inc

View File

@ -49,17 +49,17 @@ That's it. You can execute the test function now::
platform linux -- Python 3.5.2, pytest-3.0.7, py-1.4.32, pluggy-0.4.0 platform linux -- Python 3.5.2, pytest-3.0.7, py-1.4.32, pluggy-0.4.0
rootdir: $REGENDOC_TMPDIR, inifile: rootdir: $REGENDOC_TMPDIR, inifile:
collected 1 items collected 1 items
test_sample.py F test_sample.py F
======= FAILURES ======== ======= FAILURES ========
_______ test_answer ________ _______ test_answer ________
def test_answer(): def test_answer():
> assert func(3) == 5 > assert func(3) == 5
E assert 4 == 5 E assert 4 == 5
E + where 4 = func(3) E + where 4 = func(3)
test_sample.py:5: AssertionError test_sample.py:5: AssertionError
======= 1 failed in 0.12 seconds ======== ======= 1 failed in 0.12 seconds ========
@ -128,15 +128,15 @@ run the module by passing its filename::
.F .F
======= FAILURES ======== ======= FAILURES ========
_______ TestClass.test_two ________ _______ TestClass.test_two ________
self = <test_class.TestClass object at 0xdeadbeef> self = <test_class.TestClass object at 0xdeadbeef>
def test_two(self): def test_two(self):
x = "hello" x = "hello"
> assert hasattr(x, 'check') > assert hasattr(x, 'check')
E AssertionError: assert False E AssertionError: assert False
E + where False = hasattr('hello', 'check') E + where False = hasattr('hello', 'check')
test_class.py:8: AssertionError test_class.py:8: AssertionError
1 failed, 1 passed in 0.12 seconds 1 failed, 1 passed in 0.12 seconds
@ -165,14 +165,14 @@ before performing the test function call. Let's just run it::
F F
======= FAILURES ======== ======= FAILURES ========
_______ test_needsfiles ________ _______ test_needsfiles ________
tmpdir = local('PYTEST_TMPDIR/test_needsfiles0') tmpdir = local('PYTEST_TMPDIR/test_needsfiles0')
def test_needsfiles(tmpdir): def test_needsfiles(tmpdir):
print (tmpdir) print (tmpdir)
> assert 0 > assert 0
E assert 0 E assert 0
test_tmpdir.py:3: AssertionError test_tmpdir.py:3: AssertionError
--------------------------- Captured stdout call --------------------------- --------------------------- Captured stdout call ---------------------------
PYTEST_TMPDIR/test_needsfiles0 PYTEST_TMPDIR/test_needsfiles0
@ -191,8 +191,8 @@ Where to go next
Here are a few suggestions where to go next: Here are a few suggestions where to go next:
* :ref:`cmdline` for command line invocation examples * :ref:`cmdline` for command line invocation examples
* :ref:`existingtestsuite` for working with pre-existing tests
* :ref:`good practices <goodpractices>` for virtualenv, test layout * :ref:`good practices <goodpractices>` for virtualenv, test layout
* :ref:`existingtestsuite` for working with pre-existing tests
* :ref:`fixtures` for providing a functional baseline to your tests * :ref:`fixtures` for providing a functional baseline to your tests
* :ref:`plugins` managing and writing plugins * :ref:`plugins` managing and writing plugins