Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from pytest-dev/better-examples
Recreate the examples
- Loading branch information
Showing
22 changed files
with
343 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ Contents: | |
debuggers | ||
xdist | ||
subprocess-support | ||
tox | ||
plugins | ||
markers-fixtures | ||
changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
=== | ||
Tox | ||
=== | ||
|
||
When using `tox <https://tox.readthedocs.io/>`_ you can have ultra-compact configuration - you can have all of it in | ||
``tox.ini``:: | ||
|
||
[tox] | ||
envlist = ... | ||
|
||
[tool:pytest] | ||
... | ||
|
||
[coverage:paths] | ||
... | ||
|
||
[coverage:run] | ||
... | ||
|
||
[coverage:report] | ||
.. | ||
|
||
[testenv] | ||
commands = ... | ||
|
||
An usual problem users have is that pytest-cov will erase the previous coverage data by default, thus if you run tox | ||
with multiple environments you'll get incomplete coverage at the end. | ||
|
||
To prevent this problem you need to use ``--cov-append``. It's still recommended to clean the previous coverage data to | ||
have consistent output. A ``tox.ini`` like this should be enough for sequential runs:: | ||
|
||
[tox] | ||
envlist = clean,py27,py36,... | ||
|
||
[testenv] | ||
commands = pytest --cov --cov-append --cov-report=term-missing ... | ||
deps = | ||
pytest | ||
pytest-cov | ||
|
||
[testenv:clean] | ||
deps = coverage | ||
skip_install = true | ||
commands = coverage erase | ||
|
||
For parallel runs we need to set some dependencies and have an extra report env like so:: | ||
|
||
[tox] | ||
envlist = clean,py27,py36,report | ||
|
||
[testenv] | ||
commands = pytest --cov --cov-append --cov-report=term-missing | ||
deps = | ||
pytest | ||
pytest-cov | ||
depends = | ||
{py27,py36}: clean | ||
report: py27,py36 | ||
|
||
[testenv:report] | ||
deps = coverage | ||
skip_install = true | ||
commands = | ||
coverage report | ||
coverage html | ||
|
||
[testenv:clean] | ||
deps = coverage | ||
skip_install = true | ||
commands = coverage erase | ||
|
||
Depending on your project layout you might need extra configuration, see the working examples at | ||
https://github.com/pytest-dev/pytest-cov/tree/master/examples for two common layouts. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Simple examples with ``tox.ini`` | ||
================================ | ||
|
||
These examples provide necessary configuration to: | ||
|
||
* aggregate coverage from multiple interpreters | ||
* support tox parallel mode | ||
* run tests on installed code | ||
|
||
The `adhoc` layout is the old and problematic layout where you can mix up the installed code | ||
with the source code. However, these examples will provide correct configuration even for | ||
the `adhoc` layout. | ||
|
||
The `src` layout configuration is less complicated, have that in mind when picking a layout | ||
for your project. |
Oops, something went wrong.