MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_assert_tuple_warning

Function test_assert_tuple_warning

testing/test_assertion.py:1560–1579  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1558
1559@pytest.mark.filterwarnings("default")
1560def test_assert_tuple_warning(pytester: Pytester) -> None:
1561 msg = "assertion is always true"
1562 pytester.makepyfile(
1563 """
1564 def test_tuple():
1565 assert(False, 'you shall not pass')
1566 """
1567 )
1568 result = pytester.runpytest()
1569 result.stdout.fnmatch_lines([f"*test_assert_tuple_warning.py:2:*{msg}*"])
1570
1571 # tuples with size != 2 should not trigger the warning
1572 pytester.makepyfile(
1573 """
1574 def test_tuple():
1575 assert ()
1576 """
1577 )
1578 result = pytester.runpytest()
1579 assert msg not in result.stdout.str()
1580
1581
1582def test_assert_indirect_tuple_no_warning(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
strMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected