From d217984129425321b07386cf66debd816675e07b Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 10:46:15 -0700 Subject: [PATCH 01/20] documenting how to point pytest at local code Related to #1937 --- doc/en/customize.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/en/customize.rst b/doc/en/customize.rst index d12a49037..2a61aa1ef 100644 --- a/doc/en/customize.rst +++ b/doc/en/customize.rst @@ -97,6 +97,15 @@ check for ini-files as follows:: .. _`how to change command line options defaults`: .. _`adding default options`: +Change which files are added to sys.path +----------------------------------------------- +To tell pytest which files you want it to run your tests against +place both your pytest.ini file and a conftest.py file in a directory +above both your test folder and source folder. By having a conftest.py +in the root directory of your project, you can tell pytest to modify +your sys.path when it runs to include all submodules below the root of +your project. + How to change command line options defaults ------------------------------------------------ @@ -155,7 +164,7 @@ Builtin configuration file options * matches everything ? matches any single character - [seq] matches any character in seq + [seq] matches any character inbu seq [!seq] matches any char not in seq Default patterns are ``'.*', 'build', 'dist', 'CVS', '_darcs', '{arch}', '*.egg'``. From 383fc02ba6ffed96aa1f50f9e2f502caf0e9feb9 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 10:47:16 -0700 Subject: [PATCH 02/20] fix spacing --- doc/en/customize.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/en/customize.rst b/doc/en/customize.rst index 2a61aa1ef..7215c3e47 100644 --- a/doc/en/customize.rst +++ b/doc/en/customize.rst @@ -99,6 +99,7 @@ check for ini-files as follows:: Change which files are added to sys.path ----------------------------------------------- + To tell pytest which files you want it to run your tests against place both your pytest.ini file and a conftest.py file in a directory above both your test folder and source folder. By having a conftest.py From 69f72c6f4b21226a8223e05f8e1c27898347205e Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 10:49:59 -0700 Subject: [PATCH 03/20] fix typo --- doc/en/customize.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/customize.rst b/doc/en/customize.rst index 7215c3e47..dc592f693 100644 --- a/doc/en/customize.rst +++ b/doc/en/customize.rst @@ -165,7 +165,7 @@ Builtin configuration file options * matches everything ? matches any single character - [seq] matches any character inbu seq + [seq] matches any character in seq [!seq] matches any char not in seq Default patterns are ``'.*', 'build', 'dist', 'CVS', '_darcs', '{arch}', '*.egg'``. From b4fd74c6ff18af275c0a99c4ab517de6a6ccf6b3 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 14:10:57 -0700 Subject: [PATCH 04/20] add mention of setup.py develop --- doc/en/customize.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/en/customize.rst b/doc/en/customize.rst index dc592f693..3b060a715 100644 --- a/doc/en/customize.rst +++ b/doc/en/customize.rst @@ -45,7 +45,7 @@ Here is the algorithm which finds the rootdir from ``args``: matched, it becomes the ini-file and its directory becomes the rootdir. - if no ini-file was found, use the already determined common ancestor as root - directory. This allows to work with pytest in structures that are not part of + directory. This allows the use of pytest in structures that are not part of a package and don't have any particular ini-file configuration. If no ``args`` are given, pytest collects test below the current working @@ -100,12 +100,15 @@ check for ini-files as follows:: Change which files are added to sys.path ----------------------------------------------- -To tell pytest which files you want it to run your tests against -place both your pytest.ini file and a conftest.py file in a directory -above both your test folder and source folder. By having a conftest.py -in the root directory of your project, you can tell pytest to modify -your sys.path when it runs to include all submodules below the root of -your project. +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 ------------------------------------------------ From 07ad71e851fab1cf4640b9e44c62ddec66319ad2 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 14:55:54 -0700 Subject: [PATCH 05/20] clarified purpose of `pip install -e` command ref #1937 --- doc/en/goodpractices.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index 7c2fdccf2..3950171aa 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -64,6 +64,12 @@ Important notes relating to both schemes: - **make sure that "mypkg" is importable**, for example by typing once:: pip install -e . # install package using setup.py in editable mode + # similar to running python setup.py develop + + This installs your package with a symlink to your development code + instead of placing the code directly in the install directory. + This way you can edit the code and run tests on your edits without + having to reinstall every time. - **avoid "__init__.py" files in your test directories**. This way your tests can run easily against an installed version From 81a733f2dcc16214568afeafcd84a12defe10097 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 15:09:47 -0700 Subject: [PATCH 06/20] add how-to for getting started on existing project ref #1937 --- doc/en/getting-started.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 83462e3dc..d9fb3b1ff 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -185,6 +185,21 @@ You can find out what kind of builtin :ref:`fixtures` exist by typing:: pytest --fixtures # shows builtin and custom fixtures +Contributing tests to an existing project +------------------------------------- + +Say you want to contribute some tests to an existing repository. +After pulling the code into your development space using some +flavor of version control and (optionally) setting up a virtualenv +you will want to run:: + + pip install -e # Environment dependent alternatives include + # 'python setup.py develop' and 'conda develop' + +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. + Where to go next ------------------------------------- From d781b76627c6b6db6c89641f63aed7b47366b3f2 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 15:20:47 -0700 Subject: [PATCH 07/20] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index c74aa4af6..6e4655f37 100644 --- a/AUTHORS +++ b/AUTHORS @@ -115,6 +115,7 @@ Russel Winder Ryan Wooden Samuele Pedroni Simon Gomizelj +Skylar Downes Stefan Farmbauer Stefan Zimmermann Stefano Taschini From f1faaea3fdebc72419d56309ece97c0f555aa3f5 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 15:22:53 -0700 Subject: [PATCH 08/20] Update CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cc4067fc1..beeefe1d3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,7 +13,7 @@ * -* +* Added documentation related to issue #1937 .. _@philpep: https://github.com/philpep From 330a2f67841ff12f0fd69499cec39c4025fbbbe4 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 16:28:37 -0700 Subject: [PATCH 09/20] Update getting-started.rst --- doc/en/getting-started.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index d9fb3b1ff..6ed6d9ed8 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -186,14 +186,15 @@ You can find out what kind of builtin :ref:`fixtures` exist by typing:: pytest --fixtures # shows builtin and custom fixtures Contributing tests to an existing project -------------------------------------- +------------------------------------------- Say you want to contribute some tests to an existing repository. After pulling the code into your development space using some flavor of version control and (optionally) setting up a virtualenv you will want to run:: - pip install -e # Environment dependent alternatives include + cd + pip install -e . # Environment dependent alternatives include # 'python setup.py develop' and 'conda develop' in your project root. This will set up a symlink to your code in From 34117be98b8c880787469e82df2c65ee7e534500 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 15 Sep 2016 16:45:35 -0700 Subject: [PATCH 10/20] Update goodpractices.rst --- doc/en/goodpractices.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index 3950171aa..c125cc7ca 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -64,7 +64,8 @@ Important notes relating to both schemes: - **make sure that "mypkg" is importable**, for example by typing once:: pip install -e . # install package using setup.py in editable mode - # similar to running python setup.py develop + # similar to running `python setup.py develop` or + # `conda develop` This installs your package with a symlink to your development code instead of placing the code directly in the install directory. From 7e2f66adc38f3609b805ee006e0987b678f731de Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Tue, 27 Sep 2016 12:51:46 -0700 Subject: [PATCH 11/20] Create existingtestsuite.rst --- doc/en/existingtestsuite.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 doc/en/existingtestsuite.rst diff --git a/doc/en/existingtestsuite.rst b/doc/en/existingtestsuite.rst new file mode 100644 index 000000000..96ce6339c --- /dev/null +++ b/doc/en/existingtestsuite.rst @@ -0,0 +1,32 @@ +Using pytest with an existing test suite +=========================================== + +Pytest can be used with most existing test suites, but it's +behavior differs from other test runners such as :ref:`nose` or +Python's default unittest framework. + +Before using this section you will want to :ref:`getting-started `. + +Running an existing test suite with pytest +--------------------------------------------- + +Say you want to contribute to an existing repository somewhere. +After pulling the code into your development space using some +flavor of version control and (optionally) setting up a virtualenv +you will want to run:: + + cd + pip install -e . # Environment dependent alternatives include + # 'python setup.py develop' and 'conda develop' + +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. + +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 +mucking about with sys.path to point your tests at local code. + +Also consider using Tox - https://tox.readthedocs.io/en/latest/ + +.. include:: links.inc From 12ac3c7338d7a66e3c3b2e5fd742b0d49c61191b Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Tue, 27 Sep 2016 13:08:15 -0700 Subject: [PATCH 12/20] remove existing tests stuff, add link to new page Moved the "Contributing tests to an existing project" section to it's own page. --- doc/en/getting-started.rst | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 6ed6d9ed8..836498c69 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -185,28 +185,13 @@ You can find out what kind of builtin :ref:`fixtures` exist by typing:: pytest --fixtures # shows builtin and custom fixtures -Contributing tests to an existing project -------------------------------------------- - -Say you want to contribute some tests to an existing repository. -After pulling the code into your development space using some -flavor of version control and (optionally) setting up a virtualenv -you will want to run:: - - cd - pip install -e . # Environment dependent alternatives include - # 'python setup.py develop' and 'conda develop' - -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. - Where to go next ------------------------------------- Here are a few suggestions where to go next: * :ref:`cmdline` for command line invocation examples +* :ref:`existingtestsuite` for working with pre-existing tests * :ref:`good practices ` for virtualenv, test layout * :ref:`fixtures` for providing a functional baseline to your tests * :ref:`plugins` managing and writing plugins From 1ab1962eb1aaae693b1dfd00aadae3e6ba23748e Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Tue, 27 Sep 2016 13:53:31 -0700 Subject: [PATCH 13/20] make issue #1934 reference a link --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index beeefe1d3..f2119eb0b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,7 +13,7 @@ * -* Added documentation related to issue #1937 +* Added documentation related to issue (`#1937`_) .. _@philpep: https://github.com/philpep From 3d211da9bda2e79cd52dad92f91744985e0fd9a3 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Tue, 27 Sep 2016 14:01:54 -0700 Subject: [PATCH 14/20] add existing test suite page to table of contents --- doc/en/contents.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/en/contents.rst b/doc/en/contents.rst index d7f900810..ce6396e47 100644 --- a/doc/en/contents.rst +++ b/doc/en/contents.rst @@ -12,6 +12,7 @@ Full pytest documentation getting-started usage + existingtestsuite assert builtin fixture From b0c78c867dcc5b3c2ab0b3024bcaff1f29f7f975 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Tue, 27 Sep 2016 15:50:45 -0700 Subject: [PATCH 15/20] Update CHANGELOG.rst --- CHANGELOG.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f2119eb0b..c5fb31151 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,12 +14,14 @@ * * Added documentation related to issue (`#1937`_) - + Thanks `@skylarjhdownes`_ for the PR. .. _@philpep: https://github.com/philpep +.. _@skylarjhdownes: https://github.com/skylarjhdownes .. _#1905: https://github.com/pytest-dev/pytest/issues/1905 .. _#1934: https://github.com/pytest-dev/pytest/issues/1934 +.. _#1937: https://github.com/pytest-dev/pytest/issues/1937 3.0.2 From f7caa56a6b045b0541024374094c213fbcf58794 Mon Sep 17 00:00:00 2001 From: Skylar Downes Date: Thu, 6 Apr 2017 18:01:03 -0700 Subject: [PATCH 16/20] moved documentation of conftest.py hack to nose.rst --- doc/en/customize.rst | 13 +------------ doc/en/goodpractices.rst | 4 +--- doc/en/nose.rst | 11 +++++++++++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/doc/en/customize.rst b/doc/en/customize.rst index 3b060a715..e1d8fc571 100644 --- a/doc/en/customize.rst +++ b/doc/en/customize.rst @@ -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. 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 ``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`: .. _`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 ------------------------------------------------ diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index 9e8811c7f..92cd9ed81 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -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 `blog post by Ionel Cristian Mărieș `_. - Tests as part of application code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Inlining test directories into your application package is useful if you have direct relation between tests and application modules and want to distribute them along with your application:: @@ -189,7 +187,7 @@ You can then install your package in "editable" mode:: pip install -e . 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. Once you are done with your work and want to make sure that your actual diff --git a/doc/en/nose.rst b/doc/en/nose.rst index a785ecfaa..dcceff9b6 100644 --- a/doc/en/nose.rst +++ b/doc/en/nose.rst @@ -50,6 +50,16 @@ Unsupported idioms / known issues but there is discussion in `issue268 `_ for adding some support. Note that `nose2 choose to avoid this sys.path/import hackery `_. + 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, also doctest fixtures don't work. @@ -62,3 +72,4 @@ Unsupported idioms / known issues being the recommended alternative. + From 639c592f319c788ca0cf909a0ecef6fa23d47393 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 6 Apr 2017 22:59:24 -0300 Subject: [PATCH 17/20] Add missing link in CHANGELOG --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index decea4b25..fbf43bd09 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -25,6 +25,7 @@ .. _@metasyn: https://github.com/metasyn +.. _#1937: https://github.com/pytest-dev/pytest/issues/1937 .. _#2276: https://github.com/pytest-dev/pytest/issues/2276 .. _#2336: https://github.com/pytest-dev/pytest/issues/2336 From 546269792483e7a6f6e0213bd5ef3dbb29b7373b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 6 Apr 2017 23:01:26 -0300 Subject: [PATCH 18/20] Small formatting fixes to nose.rst --- doc/en/nose.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/en/nose.rst b/doc/en/nose.rst index dcceff9b6..5effd0d7b 100644 --- a/doc/en/nose.rst +++ b/doc/en/nose.rst @@ -47,16 +47,16 @@ Unsupported idioms / known issues ``tests.test_mod``) but different file system paths (e.g. ``tests/test_mode.py`` and ``other/tests/test_mode.py``) by extending sys.path/import semantics. pytest does not do that - but there is discussion in `issue268 `_ for adding some support. Note that + but there is discussion in `#268 `_ for adding some support. Note that `nose2 choose to avoid this sys.path/import hackery `_. 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 + 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 + 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. From 45852386e58e250951bbf06eb30a87e2daa5c107 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 6 Apr 2017 23:02:47 -0300 Subject: [PATCH 19/20] Fix small typo in docs --- doc/en/existingtestsuite.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/existingtestsuite.rst b/doc/en/existingtestsuite.rst index 96ce6339c..a85aaaeb5 100644 --- a/doc/en/existingtestsuite.rst +++ b/doc/en/existingtestsuite.rst @@ -1,7 +1,7 @@ Using pytest with an existing test suite =========================================== -Pytest can be used with most existing test suites, but it's +Pytest can be used with most existing test suites, but its behavior differs from other test runners such as :ref:`nose` or Python's default unittest framework. @@ -27,6 +27,6 @@ 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 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 `Tox `_. .. include:: links.inc From f2300fbab2525d3d95f125e14c0bbd9d08c58d77 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 6 Apr 2017 23:29:41 -0300 Subject: [PATCH 20/20] Fix links in docs --- doc/en/existingtestsuite.rst | 26 ++++++++++++++------------ doc/en/getting-started.rst | 22 +++++++++++----------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/doc/en/existingtestsuite.rst b/doc/en/existingtestsuite.rst index a85aaaeb5..d304b30c9 100644 --- a/doc/en/existingtestsuite.rst +++ b/doc/en/existingtestsuite.rst @@ -1,32 +1,34 @@ +.. _existingtestsuite: + Using pytest with an existing test suite =========================================== -Pytest can be used with most existing test suites, but its -behavior differs from other test runners such as :ref:`nose` or -Python's default unittest framework. +Pytest can be used with most existing test suites, but its +behavior differs from other test runners such as :ref:`nose ` or +Python's default unittest framework. -Before using this section you will want to :ref:`getting-started `. +Before using this section you will want to :ref:`install pytest `. Running an existing test suite with pytest --------------------------------------------- -Say you want to contribute to an existing repository somewhere. -After pulling the code into your development space using some +Say you want to contribute to an existing repository somewhere. +After pulling the code into your development space using some flavor of version control and (optionally) setting up a virtualenv you will want to run:: - + cd - pip install -e . # Environment dependent alternatives include - # 'python setup.py develop' and 'conda develop' + pip install -e . # Environment dependent alternatives include + # 'python setup.py develop' and 'conda develop' 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. -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 +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 mucking about with sys.path to point your tests at local code. -Also consider using `Tox `_. +Also consider using :ref:`tox `. .. include:: links.inc diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 071b296db..9f2aa2cda 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -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 rootdir: $REGENDOC_TMPDIR, inifile: collected 1 items - + test_sample.py F - + ======= FAILURES ======== _______ test_answer ________ - + def test_answer(): > assert func(3) == 5 E assert 4 == 5 E + where 4 = func(3) - + test_sample.py:5: AssertionError ======= 1 failed in 0.12 seconds ======== @@ -128,15 +128,15 @@ run the module by passing its filename:: .F ======= FAILURES ======== _______ TestClass.test_two ________ - + self = - + def test_two(self): x = "hello" > assert hasattr(x, 'check') E AssertionError: assert False E + where False = hasattr('hello', 'check') - + test_class.py:8: AssertionError 1 failed, 1 passed in 0.12 seconds @@ -165,14 +165,14 @@ before performing the test function call. Let's just run it:: F ======= FAILURES ======== _______ test_needsfiles ________ - + tmpdir = local('PYTEST_TMPDIR/test_needsfiles0') - + def test_needsfiles(tmpdir): print (tmpdir) > assert 0 E assert 0 - + test_tmpdir.py:3: AssertionError --------------------------- Captured stdout call --------------------------- PYTEST_TMPDIR/test_needsfiles0 @@ -191,8 +191,8 @@ Where to go next Here are a few suggestions where to go next: * :ref:`cmdline` for command line invocation examples -* :ref:`existingtestsuite` for working with pre-existing tests * :ref:`good practices ` for virtualenv, test layout +* :ref:`existingtestsuite` for working with pre-existing tests * :ref:`fixtures` for providing a functional baseline to your tests * :ref:`plugins` managing and writing plugins