1212import io
1313import itertools
1414import json
15- import math
1615import os
1716import time
1817import unittest
@@ -1171,15 +1170,21 @@ def test_removetree_root(self):
11711170
11721171 def test_setinfo (self ):
11731172 self .fs .create ("birthday.txt" )
1174- now = math . floor ( time .time () )
1173+ now = time .time ()
11751174
11761175 change_info = {"details" : {"accessed" : now + 60 , "modified" : now + 60 * 60 }}
11771176 self .fs .setinfo ("birthday.txt" , change_info )
1178- new_info = self .fs .getinfo ("birthday.txt" , namespaces = ["details" ]).raw
1179- if "accessed" in new_info .get ("_write" , []):
1180- self .assertEqual (new_info ["details" ]["accessed" ], now + 60 )
1181- if "modified" in new_info .get ("_write" , []):
1182- self .assertEqual (new_info ["details" ]["modified" ], now + 60 * 60 )
1177+ new_info = self .fs .getinfo ("birthday.txt" , namespaces = ["details" ])
1178+ can_write_acccess = new_info .is_writeable ("details" , "accessed" )
1179+ can_write_modified = new_info .is_writeable ("details" , "modified" )
1180+ if can_write_acccess :
1181+ self .assertAlmostEqual (
1182+ new_info .get ("details" , "accessed" ), now + 60 , places = 4
1183+ )
1184+ if can_write_modified :
1185+ self .assertAlmostEqual (
1186+ new_info .get ("details" , "modified" ), now + 60 * 60 , places = 4
1187+ )
11831188
11841189 with self .assertRaises (errors .ResourceNotFound ):
11851190 self .fs .setinfo ("nothing" , {})
@@ -1188,10 +1193,11 @@ def test_settimes(self):
11881193 self .fs .create ("birthday.txt" )
11891194 self .fs .settimes ("birthday.txt" , accessed = datetime (2016 , 7 , 5 ))
11901195 info = self .fs .getinfo ("birthday.txt" , namespaces = ["details" ])
1191- writeable = info .get ("details" , "_write" , [])
1192- if "accessed" in writeable :
1196+ can_write_acccess = info .is_writeable ("details" , "accessed" )
1197+ can_write_modified = info .is_writeable ("details" , "modified" )
1198+ if can_write_acccess :
11931199 self .assertEqual (info .accessed , datetime (2016 , 7 , 5 , tzinfo = pytz .UTC ))
1194- if "modified" in writeable :
1200+ if can_write_modified :
11951201 self .assertEqual (info .modified , datetime (2016 , 7 , 5 , tzinfo = pytz .UTC ))
11961202
11971203 def test_touch (self ):
0 commit comments