def assert_recent_datetime(
        self,
        dt: datetime.datetime,
        seconds: int = 10,
        msg: str | None = None,
    ) -> None:
        """Assert that `dt` marks a time at most `seconds` seconds ago."""
        age = datetime.datetime.now() - dt
        assert age.total_seconds() >= 0, msg
        assert age.total_seconds() <= seconds, msg
Assert that `dt` marks a time at most `seconds` seconds ago.
tests/coveragetest.py