Beispiel #1
0
def test_basic_recordwriter_write():
    test_string = "hello world"
    with EphemeralFile('w') as fp:
        fn = fp.name
        rw = RecordWriter(fp)
        rw.write(test_string)
        rw.close()
        with open(fn) as fpr:
            rr = RecordReader(fpr)
            assert rr.read() == test_string
Beispiel #2
0
def test_basic_recordwriter_write():
  test_string = "hello world"
  with EphemeralFile('w') as fp:
    fn = fp.name
    rw = RecordWriter(fp)
    rw.write(test_string)
    rw.close()
    with open(fn) as fpr:
      rr = RecordReader(fpr)
      assert rr.read() == test_string
    def test_recordwriter_framing(self):
        test_string_1 = "hello world"
        test_string_2 = "ahoy ahoy, bonjour"

        with self.EphemeralFile('w') as fp:
            fn = fp.name
            rw = RecordWriter(fp)
            rw.write(test_string_1)
            rw.close()

            with open(fn, 'a') as fpa:
                rw = RecordWriter(fpa)
                rw.write(test_string_2)

            with open(fn) as fpr:
                rr = RecordReader(fpr)
                assert rr.read() == test_string_1
                assert rr.read() == test_string_2
Beispiel #4
0
  def test_recordwriter_framing(self):
    test_string_1 = "hello world"
    test_string_2 = "ahoy ahoy, bonjour"

    with self.EphemeralFile('w') as fp:
      fn = fp.name
      rw = RecordWriter(fp)
      rw.write(test_string_1)
      rw.close()

      with open(fn, 'a') as fpa:
        rw = RecordWriter(fpa)
        rw.write(test_string_2)

      with open(fn) as fpr:
        rr = RecordReader(fpr)
        assert rr.read() == test_string_1
        assert rr.read() == test_string_2