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

Method formatTime

src/_pytest/logging.py:67–77  ·  src/_pytest/logging.py::DatetimeFormatter.formatTime
(self, record: LogRecord, datefmt: str | None = None)

Source from the content-addressed store, hash-verified

65 class="st">"""
66
67 def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str:
68 if datefmt and class="st">"%f" in datefmt:
69 ct = self.converter(record.created)
70 tz = timezone(timedelta(seconds=ct.tm_gmtoff), ct.tm_zone)
71 class="cm"># Construct `datetime.datetime` object from `struct_time`
72 class="cm"># and msecs information from `record`
73 class="cm"># Using int() instead of round() to avoid it exceeding 1_000_000 and causing a ValueError (#11861).
74 dt = datetime(*ct[0:6], microsecond=int(record.msecs * 1000), tzinfo=tz)
75 return dt.strftime(datefmt)
76 class="cm"># Use `logging.Formatter` for non-microsecond formats
77 return super().formatTime(record, datefmt)
78
79
80class ColoredLevelFormatter(DatetimeFormatter):

Callers

nothing calls this directly

Calls 1

intClass · 0.85

Tested by

no test coverage detected