mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Implement timestamp support for local files in testenv
* testenv/README: Change timestamp format definition * testenv/conf/local_files.py: Set proper timestamps
This commit is contained in:
parent
83537f2415
commit
e397a48f6a
@ -124,7 +124,7 @@ WgetFile (str name, str contents, str timestamp, dict rules)
|
||||
None except name is a mandatory paramter, one may pass only those parameters
|
||||
that are required by the File object.
|
||||
|
||||
The timestamp string should be a valid Unix Timestamp as defined in RFC xxxx.
|
||||
The timestamp string should be in a format: "YYYY-MM-DD HH:MM:SS" in UTC zone.
|
||||
The rules object is a dictionary element, with the key as the Rule Name and
|
||||
value as the Rule Data. In most cases, the Rule Data is another dictionary.
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
from os import utime
|
||||
from time import strptime
|
||||
from calendar import timegm
|
||||
from conf import hook
|
||||
|
||||
""" Pre-Test Hook: LocalFiles
|
||||
@ -16,3 +19,8 @@ class LocalFiles:
|
||||
for f in self.local_files:
|
||||
with open(f.name, 'w') as fp:
|
||||
fp.write(f.content)
|
||||
if f.timestamp is not None:
|
||||
tstamp = timegm(strptime(f.timestamp, '%Y-%m-%d %H:%M:%S'))
|
||||
atime = tstamp
|
||||
mtime = tstamp
|
||||
utime(f.name, (atime, mtime))
|
||||
|
Loading…
Reference in New Issue
Block a user