update tests due to the removal of writers.py in pyexcel 0.1.8
This commit is contained in:
parent
7e51fa6723
commit
a0b8ae16d1
|
@ -3,14 +3,12 @@ import os
|
|||
|
||||
|
||||
def create_sample_file1(file):
|
||||
w = pyexcel.Writer(file)
|
||||
data=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
|
||||
table = []
|
||||
table.append(data[:4])
|
||||
table.append(data[4:8])
|
||||
table.append(data[8:12])
|
||||
w.write_array(table)
|
||||
w.close()
|
||||
pyexcel.save_as(dest_file_name=file, array=table)
|
||||
|
||||
|
||||
class PyexcelHatWriterBase:
|
||||
|
@ -24,9 +22,7 @@ class PyexcelHatWriterBase:
|
|||
}
|
||||
|
||||
def test_series_table(self):
|
||||
w = pyexcel.Writer(self.testfile)
|
||||
w.write_dict(self.content)
|
||||
w.close()
|
||||
pyexcel.save_as(adict=self.content, dest_file_name=self.testfile)
|
||||
r = pyexcel.SeriesReader(self.testfile)
|
||||
actual = pyexcel.utils.to_dict(r)
|
||||
assert actual == self.content
|
||||
|
@ -47,9 +43,7 @@ class PyexcelWriterBase:
|
|||
]
|
||||
|
||||
def _create_a_file(self, file):
|
||||
w = pyexcel.Writer(file)
|
||||
w.write_array(self.content)
|
||||
w.close()
|
||||
pyexcel.save_as(dest_file_name=file, array=self.content)
|
||||
|
||||
def test_write_array(self):
|
||||
self._create_a_file(self.testfile)
|
||||
|
@ -66,9 +60,7 @@ class PyexcelWriterBase:
|
|||
"""
|
||||
self._create_a_file(self.testfile)
|
||||
r = pyexcel.Reader(self.testfile)
|
||||
w2 = pyexcel.Writer(self.testfile2)
|
||||
w2.write_reader(r)
|
||||
w2.close()
|
||||
r.save_as(self.testfile2)
|
||||
r2 = pyexcel.Reader(self.testfile2)
|
||||
r2.format(int)
|
||||
actual = pyexcel.utils.to_array(r2.rows())
|
||||
|
@ -78,9 +70,7 @@ class PyexcelWriterBase:
|
|||
class PyexcelMultipleSheetBase:
|
||||
|
||||
def _write_test_file(self, filename):
|
||||
w = pyexcel.BookWriter(filename)
|
||||
w.write_book_from_dict(self.content)
|
||||
w.close()
|
||||
pyexcel.save_book_as(dest_file_name=filename, bookdict=self.content)
|
||||
|
||||
def _clean_up(self):
|
||||
if os.path.exists(self.testfile2):
|
||||
|
@ -122,22 +112,6 @@ class PyexcelMultipleSheetBase:
|
|||
data = pyexcel.utils.to_array(s)
|
||||
assert self.content[s.name] == data
|
||||
|
||||
def test_write_a_book_reader(self):
|
||||
b = pyexcel.BookReader(self.testfile)
|
||||
bw = pyexcel.BookWriter(self.testfile2)
|
||||
for s in b:
|
||||
data = pyexcel.utils.to_array(s)
|
||||
sheet = bw.create_sheet(s.name)
|
||||
sheet.write_array(data)
|
||||
sheet.close()
|
||||
bw.close()
|
||||
x = pyexcel.BookReader(self.testfile2)
|
||||
for s in x:
|
||||
data = pyexcel.utils.to_array(s)
|
||||
print(data)
|
||||
print(self.content[s.name])
|
||||
assert self.content[s.name] == data
|
||||
|
||||
def test_random_access_operator(self):
|
||||
r = pyexcel.BookReader(self.testfile)
|
||||
value = r["Sheet1"][0,1]
|
||||
|
|
|
@ -26,9 +26,7 @@ class TestDateFormat:
|
|||
data = [[datetime.date(2014,12,25),
|
||||
datetime.time(11,11,11),
|
||||
datetime.datetime(2014,12,25,11,11,11)]]
|
||||
w = pe.Writer(excel_filename)
|
||||
w.write_rows(data)
|
||||
w.close()
|
||||
pe.save_as(dest_file_name=excel_filename, array=data)
|
||||
r = pe.Reader(excel_filename)
|
||||
assert isinstance(r[0,0], datetime.date) == True
|
||||
assert r[0,0].strftime("%d/%m/%y") == "25/12/14"
|
||||
|
|
|
@ -36,9 +36,7 @@ class TestAddBooks:
|
|||
3,3,3,3
|
||||
"""
|
||||
self.rows = 3
|
||||
w = pyexcel.BookWriter(file)
|
||||
w.write_book_from_dict(self.content)
|
||||
w.close()
|
||||
pyexcel.save_book_as(bookdict=self.content,dest_file_name=file)
|
||||
|
||||
def setUp(self):
|
||||
self.testfile = "multiple1.xls"
|
||||
|
|
|
@ -29,10 +29,8 @@ class TestStringIO:
|
|||
[1, 2, 3],
|
||||
[4, 5, 6]
|
||||
]
|
||||
io = StringIO()
|
||||
w = pyexcel.Writer(("xls",io))
|
||||
w.write_rows(data)
|
||||
w.close()
|
||||
io = pyexcel.save_as(dest_file_type="xls",
|
||||
array=data)
|
||||
r = pyexcel.Reader(("xls", io.getvalue()))
|
||||
result=[1, 2, 3, 4, 5, 6]
|
||||
actual = pyexcel.utils.to_array(r.enumerate())
|
||||
|
|
Loading…
Reference in New Issue