Ejemplo n.º 1
0
 def test_write_to_non_existent_directory(self):
     new_directory = self.temp_dir.child(b"new")
     new_file = new_directory.child(b"baz")
     self.assertFalse(new_directory.exists())
     FilesystemWriter(new_file).finish()
     self.assertTrue(new_directory.exists())
     self.assertTrue(new_file.exists())
Ejemplo n.º 2
0
 def test_cancelled_write(self):
     w = FilesystemWriter(self.temp_dir.child(b'bar'))
     w.write(self.test_data)
     w.cancel()
     self.assertFalse(
         self.temp_dir.child(b'bar').exists(),
         "If a write is cancelled, the file should not be left behind")
Ejemplo n.º 3
0
 def test_finished_write(self):
     w = FilesystemWriter(self.temp_dir.child(b'bar'))
     w.write(self.test_data)
     w.finish()
     with self.temp_dir.child(b'bar').open() as f:
         self.assertEqual(f.read(), self.test_data)
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     self.delay = kwargs.pop('delay')
     self._clock = kwargs.pop('_clock', reactor)
     FilesystemWriter.__init__(self, *args, **kwargs)
Ejemplo n.º 5
0
 def c(ign):
     return FilesystemWriter.write(self, data)
Ejemplo n.º 6
0
 def test_cancelled_write(self):
     w = FilesystemWriter(self.temp_dir.child('bar'))
     w.write(self.test_data)
     w.cancel()
     self.failIf(self.temp_dir.child('bar').exists(),
                 "If a write is cancelled, the file should not be left behind")
Ejemplo n.º 7
0
 def test_finished_write(self):
     w = FilesystemWriter(self.temp_dir.child('bar'))
     w.write(self.test_data)
     w.finish()
     with self.temp_dir.child('bar').open() as f:
         self.assertEqual(f.read(), self.test_data)
Ejemplo n.º 8
0
 def c(ign):
     return FilesystemWriter.write(self, data)
Ejemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     self.delay = kwargs.pop('delay')
     self._clock = kwargs.pop('_clock', reactor)
     FilesystemWriter.__init__(self, *args, **kwargs)
Ejemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     self.delay = kwargs.pop("delay")
     self._clock = kwargs.pop("_clock", reactor)
     FilesystemWriter.__init__(self, *args, **kwargs)