💚 update unit tests

This commit is contained in:
chfw 2020-10-07 22:19:58 +01:00
parent fb82cf285f
commit ca67cc9609
4 changed files with 14 additions and 18 deletions

View File

@ -30,8 +30,7 @@ from odf.table import Table, TableRow, TableCell
from odf.teletype import extractText from odf.teletype import extractText
from odf.namespaces import OFFICENS from odf.namespaces import OFFICENS
from odf.opendocument import load from odf.opendocument import load
from pyexcel_io.plugin_api import ISheet from pyexcel_io.plugin_api import ISheet, IReader, NamedContent
from pyexcel_io.plugin_api import IReader, NamedContent
class ODSSheet(ISheet): class ODSSheet(ISheet):

View File

@ -12,8 +12,7 @@ from odf.text import P
from odf.table import Table, TableRow, TableCell from odf.table import Table, TableRow, TableCell
from odf.namespaces import OFFICENS from odf.namespaces import OFFICENS
from odf.opendocument import OpenDocumentSpreadsheet from odf.opendocument import OpenDocumentSpreadsheet
from pyexcel_io.plugin_api import ISheetWriter from pyexcel_io.plugin_api import IWriter, ISheetWriter
from pyexcel_io.plugin_api import IWriter
class ODSSheetWriter(ISheetWriter): class ODSSheetWriter(ISheetWriter):

View File

@ -3,13 +3,14 @@ import os
from base import ODSCellTypes from base import ODSCellTypes
from pyexcel_ods.odsr import ODSBook from pyexcel_ods.odsr import ODSBook
from pyexcel_ods.odsw import ODSWriter from pyexcel_ods.odsw import ODSWriter
from pyexcel_io.reader import Reader
class TestODSReader(ODSCellTypes): class TestODSReader(ODSCellTypes):
def setUp(self): def setUp(self):
r = ODSBook( r = Reader("ods")
os.path.join("tests", "fixtures", "ods_formats.ods"), "ods" r.reader_class = ODSBook
) r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
self.data = r.read_all() self.data = r.read_all()
for key in self.data.keys(): for key in self.data.keys():
self.data[key] = list(self.data[key]) self.data[key] = list(self.data[key])
@ -18,16 +19,17 @@ class TestODSReader(ODSCellTypes):
class TestODSWriter(ODSCellTypes): class TestODSWriter(ODSCellTypes):
def setUp(self): def setUp(self):
r = ODSBook( r = Reader("ods")
os.path.join("tests", "fixtures", "ods_formats.ods"), "ods" r.reader_class = ODSBook
) r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
r.close()
self.data1 = r.read_all() self.data1 = r.read_all()
self.testfile = "odswriter.ods" self.testfile = "odswriter.ods"
w = ODSWriter(self.testfile, "ods") w = ODSWriter(self.testfile, "ods")
w.write(self.data1) w.write(self.data1)
w.close() w.close()
r2 = ODSBook(self.testfile, "ods") r.open(self.testfile)
self.data = r2.read_all() self.data = r.read_all()
for key in self.data.keys(): for key in self.data.keys():
self.data[key] = list(self.data[key]) self.data[key] = list(self.data[key])

View File

@ -1,7 +1,7 @@
import os import os
from base import PyexcelWriterBase, PyexcelHatWriterBase from base import PyexcelWriterBase, PyexcelHatWriterBase
from pyexcel_ods.odsr import ODSBook as Reader from pyexcel_io import get_data
from pyexcel_ods.odsw import ODSWriter as Writer from pyexcel_ods.odsw import ODSWriter as Writer
@ -16,12 +16,8 @@ class TestNativeODSWriter:
writer = Writer(self.testfile, "ods") writer = Writer(self.testfile, "ods")
writer.write(self.content) writer.write(self.content)
writer.close() writer.close()
reader = Reader(self.testfile, "ods") content = get_data(self.testfile, library="pyexcel-ods")
content = reader.read_all()
for key in content.keys():
content[key] = list(content[key])
assert content == self.content assert content == self.content
reader.close()
def tearDown(self): def tearDown(self):
if os.path.exists(self.testfile): if os.path.exists(self.testfile):