Skip to content

Commit 3bb4d8a

Browse files
committed
Also record coverage for tests
1 parent a319674 commit 3bb4d8a

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

.coveragerc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
[run]
2+
branch = True
3+
source = _pytest,testing
24
omit =
3-
# standlonetemplate is read dynamically and tested by test_genscript
4-
*standalonetemplate.py
5+
.tox/*
6+
/usr/*
7+
setup.py
8+
9+
[report]
10+
show_missing = True
11+
skip_covered = True
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__['"]:$

src/_pytest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
try:
44
from ._version import version as __version__
5-
except ImportError:
5+
except ImportError: # pragma: no cover
66
# broken installation, we don't even try
77
# unknown only works because we do poor mans version compare
88
__version__ = "unknown"

src/_pytest/_argcomplete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __call__(self, prefix, **kwargs):
8888
return completion
8989

9090

91-
if os.environ.get("_ARGCOMPLETE"):
91+
if os.environ.get("_ARGCOMPLETE"): # pragma: no cover
9292
try:
9393
import argcomplete.completers
9494
except ImportError:
@@ -99,7 +99,7 @@ def try_argcomplete(parser):
9999
argcomplete.autocomplete(parser, always_complete_options=False)
100100

101101

102-
else:
102+
else: # pragma: no cover
103103

104104
def try_argcomplete(parser):
105105
pass

src/_pytest/_code/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
builtin_repr = repr
1717

18-
if _PY3:
18+
if _PY3: # pragma: no cover
1919
from traceback import format_exception_only
20-
else:
20+
else: # pragma: no cover
2121
from ._py2traceback import format_exception_only
2222

2323

@@ -125,7 +125,7 @@ def eval(self, code, **vars):
125125
def exec_(self, code, **vars):
126126
""" exec 'code' in the frame
127127
128-
'vars' are optiona; additional local variables
128+
'vars' are optional; additional local variables
129129
"""
130130
f_locals = self.f_locals.copy()
131131
f_locals.update(vars)

testing/test_skipping.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -351,21 +351,6 @@ def test_this():
351351
"""
352352
)
353353

354-
def xtest_dynamic_xfail_set_during_setup(self, testdir):
355-
p = testdir.makepyfile(
356-
"""
357-
import pytest
358-
def setup_function(function):
359-
pytest.mark.xfail(function)
360-
def test_this():
361-
assert 0
362-
def test_that():
363-
assert 1
364-
"""
365-
)
366-
result = testdir.runpytest(p, "-rxX")
367-
result.stdout.fnmatch_lines(["*XFAIL*test_this*", "*XPASS*test_that*"])
368-
369354
def test_dynamic_xfail_no_run(self, testdir):
370355
p = testdir.makepyfile(
371356
"""

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ deps =
170170
coveralls
171171
codecov
172172
commands =
173-
coverage run --source=_pytest -m pytest testing
173+
coverage run -m pytest testing
174174
coverage report -m
175175
coveralls
176176
codecov

0 commit comments

Comments
 (0)