pytest-sftpserver
pytest-sftpserver copied to clipboard
Downloaded files get modified time in the future
I do something like
with server.serve_content({'a_dir': {'somefile.txt': "File content"}}):
...
If I then download "somefile.txt" with my pysftp client that I'm trying to test, the file gets a timestamp one hour ahead of now.
I believe this is because of this line
mtime = calendar.timegm(datetime.now().timetuple())
which appears in two places in the code. It takes the current local time (=CET in my case) and transforms it to a timestamp as though it were GMT, resulting in the offset. I recommend that it should call "datetime.utcnow()" instead.
Even better would be to have a way to set the modified time of the files in the structure passed to serve_content - the program I'm trying to test uses the modified time a fair bit.