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

Method setmtime

src/_pytest/_py/path.py:982–993  ·  view source on GitHub ↗

Set modification time for the given path. if 'mtime' is None (the default) then the file's mtime is set to current time. Note that the resolution for 'mtime' is platform dependent.

(self, mtime=None)

Source from the content-addressed store, hash-verified

980 return Stat(self, error.checked_call(os.lstat, self.strpath))
981
982 def setmtime(self, mtime=None):
983 """Set modification time for the given path. if 'mtime' is None
984 (the default) then the file's mtime is set to current time.
985
986 Note that the resolution for 'mtime' is platform dependent.
987 """
988 if mtime is None:
989 return error.checked_call(os.utime, self.strpath, mtime)
990 try:
991 return error.checked_call(os.utime, self.strpath, (-1, mtime))
992 except error.EINVAL:
993 return error.checked_call(os.utime, self.strpath, (self.atime(), mtime))
994
995 def chdir(self):
996 """Change directory to self and return old current directory"""

Callers 1

test_setmtimeMethod · 0.80

Calls 2

atimeMethod · 0.95
checked_callMethod · 0.80

Tested by 1

test_setmtimeMethod · 0.64