Skip to content

Commit ba49581

Browse files
authored
Merge pull request #6538 from blueyed/test-coverage
tests: use NotImplementedError with uncovered code
2 parents 8c4dfca + d878d9d commit ba49581

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

testing/test_runner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def test_outcomeexception_passes_except_Exception() -> None:
557557
try:
558558
raise outcomes.OutcomeException("test")
559559
except Exception:
560-
pass
560+
raise NotImplementedError()
561561

562562

563563
def test_pytest_exit() -> None:
@@ -740,8 +740,9 @@ def f():
740740
mod2 = pytest.importorskip("hello123", minversion="1.3")
741741
assert mod2 == mod
742742
except Skipped:
743-
print(_pytest._code.ExceptionInfo.from_current())
744-
pytest.fail("spurious skip")
743+
raise NotImplementedError(
744+
"spurious skip: {}".format(_pytest._code.ExceptionInfo.from_current())
745+
)
745746

746747

747748
def test_importorskip_imports_last_module_part() -> None:
@@ -759,8 +760,9 @@ def test_importorskip_dev_module(monkeypatch) -> None:
759760
with pytest.raises(Skipped):
760761
pytest.importorskip("mockmodule1", minversion="0.14.0")
761762
except Skipped:
762-
print(_pytest._code.ExceptionInfo.from_current())
763-
pytest.fail("spurious skip")
763+
raise NotImplementedError(
764+
"spurious skip: {}".format(_pytest._code.ExceptionInfo.from_current())
765+
)
764766

765767

766768
def test_importorskip_module_level(testdir) -> None:
@@ -1030,7 +1032,7 @@ def test_outcome_exception_bad_msg() -> None:
10301032
"""Check that OutcomeExceptions validate their input to prevent confusing errors (#5578)"""
10311033

10321034
def func() -> None:
1033-
pass
1035+
raise NotImplementedError()
10341036

10351037
expected = (
10361038
"OutcomeException expected string as 'msg' parameter, got 'function' instead.\n"

0 commit comments

Comments
 (0)