Skip to content

Commit 11efe05

Browse files
committed
testing: skip some unreachable code in coverage
1 parent 40301ef commit 11efe05

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

testing/code/test_excinfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def xyz():
131131
try:
132132
raise ValueError
133133
except somenoname: # type: ignore[name-defined] # noqa: F821
134-
pass
134+
pass # pragma: no cover
135135

136136
try:
137137
xyz()
@@ -475,7 +475,7 @@ def f():
475475
except BaseException:
476476
excinfo = _pytest._code.ExceptionInfo.from_current()
477477
else:
478-
assert 0, "did not raise"
478+
assert False, "did not raise"
479479

480480
pr = FormattedExcinfo()
481481
source = pr._getentrysource(excinfo.traceback[-1])

testing/code/test_source.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_source_from_lines() -> None:
5656

5757
def test_source_from_inner_function() -> None:
5858
def f():
59-
pass
59+
raise NotImplementedError()
6060

6161
source = _pytest._code.Source(f)
6262
assert str(source).startswith("def f():")
@@ -245,15 +245,15 @@ def c() -> None:
245245

246246
def test_getfuncsource_dynamic() -> None:
247247
def f():
248-
raise ValueError
248+
raise NotImplementedError()
249249

250250
def g():
251-
pass
251+
pass # pragma: no cover
252252

253253
f_source = _pytest._code.Source(f)
254254
g_source = _pytest._code.Source(g)
255-
assert str(f_source).strip() == "def f():\n raise ValueError"
256-
assert str(g_source).strip() == "def g():\n pass"
255+
assert str(f_source).strip() == "def f():\n raise NotImplementedError()"
256+
assert str(g_source).strip() == "def g():\n pass # pragma: no cover"
257257

258258

259259
def test_getfuncsource_with_multine_string() -> None:

0 commit comments

Comments
 (0)