def test_json_newline(self, tmpdir):
        path = str(tmpdir.join('test_json_items.txt'))
        ser = CustomSerializer(lambda o: json.dumps(o), lambda l: json.loads(l))
        fs = FileSequence(path, ser)

        items = ['hey\nthere', 'two\nobjects serialized']
        fs.extend(items)

        for i, val in enumerate(fs):
            assert val == items[i]
Exemple #2
0
    def test_json_newline(self, tmpdir):
        path = str(tmpdir.join('test_json_items.txt'))
        ser = CustomSerializer(lambda o: json.dumps(o), lambda l: json.loads(l))
        fs = FileSequence(path, ser)

        items = ['hey\nthere', 'two\nobjects serialized']
        fs.extend(items)

        for i, val in enumerate(fs):
            assert val == items[i]
    def test_reload(self, empty_list, reference_list):
        empty_list.extend(reference_list)
        l = empty_list
        new_l = FileSequence(l.path, l._ser)

        assert len(new_l) == len(l)
        for i1, i2 in zip(new_l, l):
            assert i1 == i2
 def empty_list(self, tmpdir):
     path = tmpdir.join('test_file_list.txt')
     # whether to use gzip
     with FileSequence(str(path), FileSerializerExample()) as seq:
         yield seq