def test_section_failing(self): l = SimpleLog() with l.s("some"): raise ValueError() lines = str(l).splitlines() assert "some" in lines[0] assert "Traceback" in lines[2]
def test_section(self): l = SimpleLog() with l.s("title"): l("hello") l("world") l("back") lines = str(l).splitlines() assert "title" in lines[0] assert not lines[1].strip() assert " hello" == lines[2] assert " world" == lines[3] assert not lines[4].strip() assert lines[5] == "back" with l.s("title2"): l("line2") l("back") lines = str(l).splitlines() assert not lines[6].strip() assert "title2" in lines[7] assert not lines[8].strip() assert lines[9] == " " + "line2" assert not lines[10].strip() assert lines[11] == "back"
def test_section_failing_raising(self): l = SimpleLog() with pytest.raises(ValueError): with l.s("some", raising=True): raise ValueError() assert "some" in str(l)
def test_basic(self): l = SimpleLog() l("hello") l("world") assert str(l) == "hello\nworld"