Exemplo n.º 1
0
    def test_closing(self):
        from bobtools.io import JSONL

        filename = "test_tmpfile"
        if os.path.exists(filename):
            os.remove(filename)
        jsonl = JSONL(filename)
        self.assertTrue(os.path.exists(filename))
        self.assertEqual(jsonl.closed(), False)
        jsonl.close()
        self.assertEqual(jsonl.closed(), True)
        os.remove(filename)
Exemplo n.º 2
0
    def test_write_and_read_gzip_double_extension(self):
        from bobtools.io import JSONL

        filename = "test_tmpfile.jsonl.gzip"
        if os.path.exists(filename):
            os.remove(filename)

        data = ["string", 1, {"a": "b"}, [1, 2], 1.2]

        jsonl_writer = JSONL(filename)
        jsonl_writer.extend(data)
        jsonl_writer.close()
        jsonl_reader = JSONL(filename)
        read_data = jsonl_reader.read()

        self.assertEqual(data, read_data)

        os.remove(filename)