diff --git a/.coveragerc b/.coveragerc index 61ff66749dc..dcf8f3dd456 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,23 @@ [run] +branch = True +source = _pytest,testing omit = - # standlonetemplate is read dynamically and tested by test_genscript - *standalonetemplate.py + .tox/* + /usr/* + setup.py + +[report] +show_missing = True +skip_covered = True +exclude_lines= + # Have to re-enable the standard pragma + \#\s*pragma: no cover + + # Don't complain if tests don't hit defensive assertion code: + ^\s*raise AssertionError\b + ^\s*raise NotImplementedError\b + ^\s*return NotImplemented\b + ^\s*raise$ + + # Don't complain if non-runnable code isn't run: + ^if __name__ == ['"]__main__['"]:$ diff --git a/src/_pytest/__init__.py b/src/_pytest/__init__.py index 46c7827ed5e..5e5ea8cb3c6 100644 --- a/src/_pytest/__init__.py +++ b/src/_pytest/__init__.py @@ -2,7 +2,7 @@ try: from ._version import version as __version__ -except ImportError: +except ImportError: # pragma: no cover # broken installation, we don't even try # unknown only works because we do poor mans version compare __version__ = "unknown" diff --git a/src/_pytest/_argcomplete.py b/src/_pytest/_argcomplete.py index 8f480d71d79..cbd0ca40695 100644 --- a/src/_pytest/_argcomplete.py +++ b/src/_pytest/_argcomplete.py @@ -88,7 +88,7 @@ def __call__(self, prefix, **kwargs): return completion -if os.environ.get("_ARGCOMPLETE"): +if os.environ.get("_ARGCOMPLETE"): # pragma: no cover try: import argcomplete.completers except ImportError: @@ -99,7 +99,7 @@ def try_argcomplete(parser): argcomplete.autocomplete(parser, always_complete_options=False) -else: +else: # pragma: no cover def try_argcomplete(parser): pass diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 2662e432016..3fe5f2de733 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -15,9 +15,9 @@ builtin_repr = repr -if _PY3: +if _PY3: # pragma: no cover from traceback import format_exception_only -else: +else: # pragma: no cover from ._py2traceback import format_exception_only @@ -125,7 +125,7 @@ def eval(self, code, **vars): def exec_(self, code, **vars): """ exec 'code' in the frame - 'vars' are optiona; additional local variables + 'vars' are optional; additional local variables """ f_locals = self.f_locals.copy() f_locals.update(vars) diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 507ce126ad2..5a73474d1de 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -351,21 +351,6 @@ def test_this(): """ ) - def xtest_dynamic_xfail_set_during_setup(self, testdir): - p = testdir.makepyfile( - """ - import pytest - def setup_function(function): - pytest.mark.xfail(function) - def test_this(): - assert 0 - def test_that(): - assert 1 - """ - ) - result = testdir.runpytest(p, "-rxX") - result.stdout.fnmatch_lines(["*XFAIL*test_this*", "*XPASS*test_that*"]) - def test_dynamic_xfail_no_run(self, testdir): p = testdir.makepyfile( """ diff --git a/tox.ini b/tox.ini index 1ca17370fb7..719e77000fc 100644 --- a/tox.ini +++ b/tox.ini @@ -170,7 +170,7 @@ deps = coveralls codecov commands = - coverage run --source=_pytest -m pytest testing + coverage run -m pytest testing coverage report -m coveralls codecov