Skip to content

Commit ba79a8e

Browse files
committed
Recreate the examples to solve common user problems regarding cov data aggregation and layout.
1 parent 4971a3f commit ba79a8e

File tree

16 files changed

+134
-47
lines changed

16 files changed

+134
-47
lines changed

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
graft docs
2-
graft example
2+
graft examples
33
graft src
44
graft ci
55
graft tests

example/.coveragerc

-2
This file was deleted.

example/setup.py

-7
This file was deleted.

example/tests/test_mylib.py

-7
This file was deleted.

example/tox.ini

-30
This file was deleted.

examples/README.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Simple examples with ``tox.ini``
2+
================================
3+
4+
These examples provide necessary configuration to:
5+
6+
* aggregate coverage from multiple interpreters
7+
* support tox parallel mode
8+
* run tests on installed code
9+
10+
The `adhoc` layout is the old and problematic layout where you can mix up the installed code
11+
with the source code. However, these examples will provide correct configuration even for
12+
the `adhoc` layout.
13+
14+
The `src` layout configuration is less complicated, have that in mind when picking a layout
15+
for your project.

examples/adhoc-layout/.coveragerc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[paths]
2+
source =
3+
../example
4+
*/site-packages/example
5+
6+
[run]
7+
branch = true
8+
parallel = true
9+
source =
10+
example
11+
.
12+
13+
[report]
14+
show_missing = true
15+
precision = 2
File renamed without changes.

examples/adhoc-layout/setup.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from setuptools import setup, find_packages
2+
3+
4+
setup(
5+
name='example',
6+
packages=find_packages(include=['example'])
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import example
2+
3+
4+
def test_add():
5+
assert example.add(1, 1) == 2
6+
assert not example.add(0, 1) == 2

examples/adhoc-layout/tox.ini

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[tox]
2+
envlist = clean,py27,py36,report
3+
4+
[testenv]
5+
commands = pytest --cov --cov-config={toxinidir}/.coveragerc --cov-report=term-missing --cov-append {posargs:-vv}
6+
deps =
7+
pytest
8+
pytest-cov
9+
depends =
10+
{py27,py36}: clean
11+
report: py27,py36
12+
changedir = tests
13+
14+
[testenv:report]
15+
deps = coverage
16+
skip_install = true
17+
commands =
18+
coverage report
19+
coverage html
20+
21+
[testenv:clean]
22+
commands = coverage erase
23+
skip_install = true

examples/src-layout/.coveragerc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[paths]
2+
source =
3+
src
4+
*/site-packages
5+
6+
[run]
7+
branch = true
8+
parallel = true
9+
source =
10+
example
11+
tests
12+
13+
[report]
14+
show_missing = true
15+
precision = 2

examples/src-layout/setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from setuptools import setup, find_packages
2+
3+
4+
setup(
5+
name='example',
6+
packages=find_packages('src'),
7+
package_dir={'': 'src'},
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import sys
3+
4+
PY3 = sys.version_info[0] == 3
5+
6+
7+
if PY3:
8+
def add(a, b):
9+
return a + b
10+
11+
else:
12+
def add(a, b):
13+
return b + a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import example
2+
3+
4+
def test_add():
5+
assert example.add(1, 1) == 2
6+
assert not example.add(0, 1) == 2

examples/src-layout/tox.ini

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[tox]
2+
envlist = clean,py27,py36,report
3+
4+
[tool:pytest]
5+
testpaths = tests
6+
7+
[testenv]
8+
commands = pytest --cov --cov-report=term-missing --cov-append {posargs:-vv}
9+
deps =
10+
pytest
11+
pytest-cov
12+
depends =
13+
{py27,py36}: clean
14+
report: py27,py36
15+
16+
[testenv:report]
17+
deps = coverage
18+
skip_install = true
19+
commands =
20+
coverage report
21+
coverage html
22+
23+
[testenv:clean]
24+
commands = coverage erase
25+
skip_install = true

0 commit comments

Comments
 (0)