def test_truncate(self):
     with fatfs.open(f"/{self._filename()}", "w") as f:
         f.write(bytearray(b"test" * 100))
     s = fatfs.stat(f"/{self._filename()}")
     self.assertEqual(s, (400, "----a", self._filename()))
     with fatfs.open(f"/{self._filename()}", "a") as f:
         f.seek(111)
         f.truncate()
     s = fatfs.stat(f"/{self._filename()}")
     self.assertEqual(s, (111, "----a", self._filename()))
 def test_unlink(self):
     fatfs.mkdir(f"/{self._dirname()}")
     with fatfs.open(f"/{self._filename()}", "w") as f:
         f.write(bytearray(b"test"))
     s = fatfs.stat(f"/{self._dirname()}")
     self.assertEqual(s, (0, "---d-", self._dirname()))
     s = fatfs.stat(f"/{self._filename()}")
     self.assertEqual(s, (4, "----a", self._filename()))
     fatfs.unlink(f"/{self._dirname()}")
     fatfs.unlink(f"/{self._filename()}")
     with self.assertRaises(fatfs.FatFSError):
         fatfs.stat(f"/{self._dirname()}")
     with self.assertRaises(fatfs.FatFSError):
         self.assertRaises(fatfs.stat(f"/{self._filename()}"))
Esempio n. 3
0
 def test_unlink(self):
     fatfs.mkdir("/%s" % self._dirname())
     with fatfs.open("/%s" % self._filename(), "w") as f:
         f.write(bytearray(b"test"))
     s = fatfs.stat("/%s" % self._dirname())
     self.assertEqual(s, (0, "---d-", self._dirname()))
     s = fatfs.stat("/%s" % self._filename())
     self.assertEqual(s, (4, "----a", self._filename()))
     fatfs.unlink("/%s" % self._dirname())
     fatfs.unlink("/%s" % self._filename())
     with self.assertRaises(OSError):
         fatfs.stat("/%s" % self._dirname())
     with self.assertRaises(OSError):
         self.assertRaises(fatfs.stat("/%s" % self._filename()))
 def test_mkdir(self):
     fatfs.mkdir(f"/{self._dirname()}")
     s = fatfs.stat(f"/{self._dirname()}")
     self.assertEqual(s, (0, "---d-", self._dirname()))
 def test_mkdir(self):
     fatfs.mkdir("/%s" % self._dirname())
     s = fatfs.stat("/%s" % self._dirname())
     self.assertEqual(s, (0, "---d-", self._dirname()))