MCPcopy
hub / github.com/pytest-dev/pytest / test_name

Method test_name

testing/test_assertrewrite.py:394–426  ·  testing/test_assertrewrite.py::TestAssertionRewrite.test_name
(self, request)

Source from the content-addressed store, hash-verified

392 pytester.runpytest().assert_outcomes(passed=1)
393
394 def test_name(self, request) -> None:
395 def f1() -> None:
396 assert False
397
398 assert getmsg(f1) == class="st">"assert False"
399
400 def f2() -> None:
401 f = False
402 assert f
403
404 assert getmsg(f2) == class="st">"assert False"
405
406 def f3() -> None:
407 assert a_global class="cm"># type: ignore[name-defined] # noqa: F821
408
409 assert getmsg(f3, {class="st">"a_global": False}) == class="st">"assert False"
410
411 def f4() -> None:
412 assert sys == 42 class="cm"># type: ignore[comparison-overlap]
413
414 msg = getmsg(f4, {class="st">"sys": sys})
415 assert msg == class="st">"assert sys == 42"
416
417 def f5() -> None:
418 assert cls == 42 class="cm"># type: ignore[name-defined] # noqa: F821
419
420 class X:
421 pass
422
423 msg = getmsg(f5, {class="st">"cls": X})
424 assert msg is not None
425 lines = msg.splitlines()
426 assert lines == [class="st">"assert cls == 42"]
427
428 def test_assertrepr_compare_same_width(self, request) -> None:
429 class="st">""class="st">"Should use same width/truncation with same initial width."class="st">""

Callers

nothing calls this directly

Calls 1

getmsgFunction · 0.85

Tested by

no test coverage detected