debian-python-pyexcel-ods/tests/test_writer.py

46 lines
1.3 KiB
Python
Raw Normal View History

import os
2019-11-10 17:30:00 +01:00
from base import PyexcelWriterBase, PyexcelHatWriterBase
2020-10-07 23:19:58 +02:00
from pyexcel_io import get_data
from pyexcel_ods.odsw import ODSWriter as Writer
2014-10-15 20:07:13 +02:00
2014-10-15 18:28:17 +02:00
class TestNativeODSWriter:
def test_write_book(self):
self.content = {
"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
"Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]],
2014-10-15 18:28:17 +02:00
}
2017-02-03 00:22:00 +01:00
self.testfile = "writer.ods"
writer = Writer(self.testfile, "ods")
2014-10-15 18:28:17 +02:00
writer.write(self.content)
writer.close()
2020-10-07 23:19:58 +02:00
content = get_data(self.testfile, library="pyexcel-ods")
2014-10-15 18:28:17 +02:00
assert content == self.content
def tearDown(self):
if os.path.exists(self.testfile):
os.unlink(self.testfile)
2017-02-03 00:22:00 +01:00
class TestodsnCSVWriter(PyexcelWriterBase):
def setUp(self):
2017-02-03 00:22:00 +01:00
self.testfile = "test.ods"
2016-06-09 00:43:46 +02:00
self.testfile2 = "test.csv"
def tearDown(self):
if os.path.exists(self.testfile):
os.unlink(self.testfile)
if os.path.exists(self.testfile2):
os.unlink(self.testfile2)
2017-02-03 00:22:00 +01:00
class TestodsHatWriter(PyexcelHatWriterBase):
def setUp(self):
2017-02-03 00:22:00 +01:00
self.testfile = "test.ods"
def tearDown(self):
if os.path.exists(self.testfile):
os.unlink(self.testfile)