Example #1
0
 def test_repr_source(self):
     pr = FormattedExcinfo()
     source = py.code.Source("""
         def f(x):
             pass
     """).strip()
     pr.flow_marker = "|"
     lines = pr.get_source(source, 0)
     assert len(lines) == 2
     assert lines[0] == "|   def f(x):"
     assert lines[1] == "        pass"
 def test_repr_source(self):
     pr = FormattedExcinfo()
     source = py.code.Source("""
         def f(x):
             pass
     """).strip()
     pr.flow_marker = "|"
     lines = pr.get_source(source, 0)
     assert len(lines) == 2
     assert lines[0] == "|   def f(x):"
     assert lines[1] == "        pass"
Example #3
0
 def test_repr_source_excinfo(self):
     """ check if indentation is right """
     pr = FormattedExcinfo()
     excinfo = self.excinfo_from_exec("""
             def f():
                 assert 0
             f()
     """)
     pr = FormattedExcinfo()
     source = pr._getentrysource(excinfo.traceback[-1])
     lines = pr.get_source(source, 1, excinfo)
     assert lines == [
         '    def f():', '>       assert 0', 'E       assert 0'
     ]
 def test_repr_source_excinfo(self):
     """ check if indentation is right """
     pr = FormattedExcinfo()
     excinfo = self.excinfo_from_exec("""
             def f():
                 assert 0
             f()
     """)
     pr = FormattedExcinfo()
     source = pr._getentrysource(excinfo.traceback[-1])
     lines = pr.get_source(source, 1, excinfo)
     assert lines == [
         '    def f():',
         '>       assert 0',
         'E       assert 0'
     ]