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

Method test_toterminal_long

testing/code/test_excinfo.py:923–952  ·  view source on GitHub ↗
(self, importasmod, tw_mock)

Source from the content-addressed store, hash-verified

921 assert x == "я"
922
923 def test_toterminal_long(self, importasmod, tw_mock):
924 mod = importasmod(
925 """
926 def g(x):
927 raise ValueError(x)
928 def f():
929 g(3)
930 """
931 )
932 excinfo = pytest.raises(ValueError, mod.f)
933 excinfo.traceback = excinfo.traceback.filter()
934 repr = excinfo.getrepr()
935 repr.toterminal(tw_mock)
936 assert tw_mock.lines[0] == ""
937 tw_mock.lines.pop(0)
938 assert tw_mock.lines[0] == " def f():"
939 assert tw_mock.lines[1] == "> g(3)"
940 assert tw_mock.lines[2] == ""
941 line = tw_mock.get_write_msg(3)
942 assert line.endswith("mod.py")
943 assert tw_mock.lines[4] == (":5: ")
944 assert tw_mock.lines[5] == ("_ ", None)
945 assert tw_mock.lines[6] == ""
946 assert tw_mock.lines[7] == " def g(x):"
947 assert tw_mock.lines[8] == "> raise ValueError(x)"
948 assert tw_mock.lines[9] == "E ValueError: 3"
949 assert tw_mock.lines[10] == ""
950 line = tw_mock.get_write_msg(11)
951 assert line.endswith("mod.py")
952 assert tw_mock.lines[12] == ":3: ValueError"
953
954 def test_toterminal_long_missing_source(
955 self, importasmod, tmp_path: Path, tw_mock

Callers

nothing calls this directly

Calls 5

getreprMethod · 0.80
popMethod · 0.80
get_write_msgMethod · 0.80
filterMethod · 0.45
toterminalMethod · 0.45

Tested by

no test coverage detected