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

Method _getindent

src/_pytest/_code/code.py:900–913  ·  src/_pytest/_code/code.py::ExceptionInfoFormatter._getindent
(self, source: Source)

Source from the content-addressed store, hash-verified

898 )
899
900 def _getindent(self, source: Source) -> int:
901 class="cm"># Figure out indent for the given source.
902 try:
903 s = str(source.getstatement(len(source) - 1))
904 except KeyboardInterrupt:
905 raise
906 except BaseException:
907 try:
908 s = str(source[-1])
909 except KeyboardInterrupt:
910 raise
911 except BaseException:
912 return 0
913 return 4 + (len(s) - len(s.lstrip()))
914
915 def _getentrysource(self, entry: TracebackEntry) -> Source | None:
916 source = entry.getsource(self.astcache)

Callers 1

get_sourceMethod · 0.95

Calls 1

getstatementMethod · 0.80

Tested by

no test coverage detected