Skip to content

Commit ca67cc9

Browse files
committed
💚 update unit tests
1 parent fb82cf2 commit ca67cc9

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

pyexcel_ods/odsr.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
from odf.teletype import extractText
3131
from odf.namespaces import OFFICENS
3232
from odf.opendocument import load
33-
from pyexcel_io.plugin_api import ISheet
34-
from pyexcel_io.plugin_api import IReader, NamedContent
33+
from pyexcel_io.plugin_api import ISheet, IReader, NamedContent
3534

3635

3736
class ODSSheet(ISheet):

pyexcel_ods/odsw.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from odf.table import Table, TableRow, TableCell
1313
from odf.namespaces import OFFICENS
1414
from odf.opendocument import OpenDocumentSpreadsheet
15-
from pyexcel_io.plugin_api import ISheetWriter
16-
from pyexcel_io.plugin_api import IWriter
15+
from pyexcel_io.plugin_api import IWriter, ISheetWriter
1716

1817

1918
class ODSSheetWriter(ISheetWriter):

tests/test_ods_reader.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
from base import ODSCellTypes
44
from pyexcel_ods.odsr import ODSBook
55
from pyexcel_ods.odsw import ODSWriter
6+
from pyexcel_io.reader import Reader
67

78

89
class TestODSReader(ODSCellTypes):
910
def setUp(self):
10-
r = ODSBook(
11-
os.path.join("tests", "fixtures", "ods_formats.ods"), "ods"
12-
)
11+
r = Reader("ods")
12+
r.reader_class = ODSBook
13+
r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
1314
self.data = r.read_all()
1415
for key in self.data.keys():
1516
self.data[key] = list(self.data[key])
@@ -18,16 +19,17 @@ def setUp(self):
1819

1920
class TestODSWriter(ODSCellTypes):
2021
def setUp(self):
21-
r = ODSBook(
22-
os.path.join("tests", "fixtures", "ods_formats.ods"), "ods"
23-
)
22+
r = Reader("ods")
23+
r.reader_class = ODSBook
24+
r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
25+
r.close()
2426
self.data1 = r.read_all()
2527
self.testfile = "odswriter.ods"
2628
w = ODSWriter(self.testfile, "ods")
2729
w.write(self.data1)
2830
w.close()
29-
r2 = ODSBook(self.testfile, "ods")
30-
self.data = r2.read_all()
31+
r.open(self.testfile)
32+
self.data = r.read_all()
3133
for key in self.data.keys():
3234
self.data[key] = list(self.data[key])
3335

tests/test_writer.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
from base import PyexcelWriterBase, PyexcelHatWriterBase
4-
from pyexcel_ods.odsr import ODSBook as Reader
4+
from pyexcel_io import get_data
55
from pyexcel_ods.odsw import ODSWriter as Writer
66

77

@@ -16,12 +16,8 @@ def test_write_book(self):
1616
writer = Writer(self.testfile, "ods")
1717
writer.write(self.content)
1818
writer.close()
19-
reader = Reader(self.testfile, "ods")
20-
content = reader.read_all()
21-
for key in content.keys():
22-
content[key] = list(content[key])
19+
content = get_data(self.testfile, library="pyexcel-ods")
2320
assert content == self.content
24-
reader.close()
2521

2622
def tearDown(self):
2723
if os.path.exists(self.testfile):

0 commit comments

Comments
 (0)