Example #1
0
 def test_clear(self):
     d = {'truth': 42}
     with open(self.filepath, 'w') as f:
         json.dump(d, f)
     df = DictFile(self.filepath)
     df.clear()
     # Ensure its empty
     self.assertEqual(df, {})
     # Ensure its empty, even if we re-read the file from the filesystem
     self.assertEqual(DictFile(self.filepath), {})
Example #2
0
 def test_save(self):
     df1 = DictFile(self.filepath)
     df1['truth'] = 42
     df1.save()
     df2 = DictFile(self.filepath)
     self.assertEqual(df2['truth'], 42)