moved documentation of conftest.py hack to nose.rst

This commit is contained in:
Skylar Downes 2017-04-06 18:01:03 -07:00
parent 3aa4fb62d6
commit f7caa56a6b
3 changed files with 13 additions and 15 deletions

View File

@ -49,7 +49,7 @@ Here is the algorithm which finds the rootdir from ``args``:
a package and don't have any particular ini-file configuration. a package and don't have any particular ini-file configuration.
If no ``args`` are given, pytest collects test below the current working If no ``args`` are given, pytest collects test below the current working
directory and also starts determining the rootdir from there. directory and also starts determining the rootdir from there.
:warning: custom pytest plugin commandline arguments may include a path, as in :warning: custom pytest plugin commandline arguments may include a path, as in
``pytest --log-output ../../test.log args``. Then ``args`` is mandatory, ``pytest --log-output ../../test.log args``. Then ``args`` is mandatory,
@ -97,18 +97,7 @@ check for ini-files as follows::
.. _`how to change command line options defaults`: .. _`how to change command line options defaults`:
.. _`adding default options`: .. _`adding default options`:
Change which files are added to sys.path
-----------------------------------------------
If you place a conftest.py file in the root directory of your project
(as determined by pytest, see above.) pytest will run tests against
the code below that directory by adding it to your sys.path instead of
running against your installed code.
You may find yourself wanting to do this if you ran `python setup.py install`
to set up your project, as opposed to `python setup.py develop` or any of
the package manager equivalents. Installing with develop in a
virtual environment is recommended over using the conftest.py pattern.
How to change command line options defaults How to change command line options defaults
------------------------------------------------ ------------------------------------------------

View File

@ -104,11 +104,9 @@ sub-directory of your root::
This layout prevents a lot of common pitfalls and has many benefits, which are better explained in this excellent This layout prevents a lot of common pitfalls and has many benefits, which are better explained in this excellent
`blog post by Ionel Cristian Mărieș <https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure>`_. `blog post by Ionel Cristian Mărieș <https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure>`_.
Tests as part of application code Tests as part of application code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Inlining test directories into your application package Inlining test directories into your application package
is useful if you have direct relation between tests and application modules and is useful if you have direct relation between tests and application modules and
want to distribute them along with your application:: want to distribute them along with your application::
@ -189,7 +187,7 @@ You can then install your package in "editable" mode::
pip install -e . pip install -e .
which lets you change your source code (both tests and application) and rerun tests at will. which lets you change your source code (both tests and application) and rerun tests at will.
This is similar to running `python setup.py develop` or `conda develop` in that it installs This is similar to running `python setup.py develop` or `conda develop` in that it installs
your package using a symlink to your development code. your package using a symlink to your development code.
Once you are done with your work and want to make sure that your actual Once you are done with your work and want to make sure that your actual

View File

@ -50,6 +50,16 @@ Unsupported idioms / known issues
but there is discussion in `issue268 <https://github.com/pytest-dev/pytest/issues/268>`_ for adding some support. Note that but there is discussion in `issue268 <https://github.com/pytest-dev/pytest/issues/268>`_ for adding some support. Note that
`nose2 choose to avoid this sys.path/import hackery <https://nose2.readthedocs.io/en/latest/differences.html#test-discovery-and-loading>`_. `nose2 choose to avoid this sys.path/import hackery <https://nose2.readthedocs.io/en/latest/differences.html#test-discovery-and-loading>`_.
If you place a conftest.py file in the root directory of your project
(as determined by pytest) pytest will run tests "nose style" against
the code below that directory by adding it to your sys.path instead of
running against your installed code.
You may find yourself wanting to do this if you ran `python setup.py install`
to set up your project, as opposed to `python setup.py develop` or any of
the package manager equivalents. Installing with develop in a
virtual environment like Tox is recommended over this pattern.
- nose-style doctests are not collected and executed correctly, - nose-style doctests are not collected and executed correctly,
also doctest fixtures don't work. also doctest fixtures don't work.
@ -62,3 +72,4 @@ Unsupported idioms / known issues
being the recommended alternative. being the recommended alternative.