Ejemplo n.º 1
0
  def testCanIterate(self):
    path = TempDir() + "/ring"

    ringfile = Ringfile.create(path, 1024)
    ringfile.write("Hello, World!")
    ringfile.close()

    ringfile = Ringfile(path, MODE_APPEND)
    ringfile.write("Goodbye, World!")
    ringfile.close()

    records = list(Ringfile(path, MODE_READ))
    self.assertEqual(["Hello, World!", "Goodbye, World!"], records)
Ejemplo n.º 2
0
  def testCanReadAndWriteBasics(self):
    path = TempDir() + "/ring"

    ringfile = Ringfile.create(path, 1024)
    ringfile.write("Hello, World!")
    ringfile.close()

    ringfile = Ringfile(path, MODE_APPEND)
    ringfile.write("Goodbye, World!")
    ringfile.close()

    ringfile = Ringfile(path, MODE_READ)
    self.assertEqual("Hello, World!", ringfile.read())
    self.assertEqual("Goodbye, World!", ringfile.read())
    self.assertEqual(None, ringfile.read())