Skip to content

Commit 2d06b3d

Browse files
committed
Add code coverage to paasta unit test targets
1 parent a3eb188 commit 2d06b3d

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

.coveragerc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[run]
2+
source =
3+
.
4+
omit =
5+
.tox/*
6+
.paasta/*
7+
tests/*
8+
setup.py
9+
10+
[report]
11+
12+
exclude_lines =
13+
# Have to re-enable the standard pragma
14+
\#\s*pragma: no cover
15+
16+
# Don't complain if tests don't hit defensive assertion code:
17+
^\s*raise AssertionError\b
18+
^\s*raise NotImplementedError\b
19+
^\s*return NotImplemented\b
20+
^\s*raise$
21+
22+
# Don't complain if non-runnable code isn't run:
23+
^if __name__ == ['"]__main__['"]:$

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ example_cluster/paasta/docker_registry.json
4646
general_itests/fake_etc_paasta/clusters.json
4747
pip-wheel-metadata
4848
debian/debhelper-build-stamp
49+
50+
# Coverage artifacts
51+
.coverage

requirements-dev-minimal.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
astroid
22
asynctest
3+
coverage
34
docutils
45
flake8
56
freezegun

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ astroid==2.4.2
55
asynctest==0.12.0
66
Babel==2.9.1
77
cfgv==2.0.1
8+
coverage==6.5.0
89
distlib==0.3.4
910
filelock==3.0.12
1011
flake8==3.5.0

tests/test_marathon_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ def test_get_marathon_client(self):
16681668
)
16691669
args, kwargs = client_patch.call_args
16701670
assert "User-Agent" in kwargs["session"].headers
1671-
assert "py.test" in kwargs["session"].headers["User-Agent"]
1671+
assert "test" in kwargs["session"].headers["User-Agent"]
16721672

16731673
def test_list_all_marathon_app_ids(self):
16741674
fakeapp1 = mock.Mock(id="/fake_app1")

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ commands =
5959
check-requirements -vv
6060
pre-commit install -f --install-hooks
6161
pre-commit run --all-files
62-
py.test {posargs:tests}
62+
coverage erase
63+
coverage run -m py.test {posargs:tests}
64+
coverage report -m
6365

6466
[testenv:tests-yelpy]
6567
envdir = .tox/py37-linux/
@@ -72,7 +74,9 @@ commands =
7274
check-requirements -vv
7375
pre-commit install -f --install-hooks
7476
pre-commit run --all-files
75-
py.test {posargs:tests}
77+
coverage erase
78+
coverage run -m py.test {posargs:tests}
79+
coverage report -m
7680

7781
[testenv:docs]
7882
commands =

0 commit comments

Comments
 (0)