11from testapp import app
22import pyexcel as pe
3- from _compact import OrderedDict , BytesIO
3+ from _compact import OrderedDict
44
55
66class TestSheet :
@@ -16,16 +16,14 @@ def setUp(self):
1616 def test_array (self ):
1717 for struct_type in ["array" , "dict" , "records" ]:
1818 print ("Testing %s" % struct_type )
19- io = BytesIO ()
20- sheet = pe .Sheet (self .data )
21- sheet .save_to_memory ('xls' , io )
19+ io = pe .save_as (dest_file_type = "xls" , array = self .data )
2220 io .seek (0 )
2321 response = self .app .post ('/exchange/%s' % struct_type ,
2422 buffered = True ,
2523 data = {"file" : (io , "test.xls" )},
2624 content_type = "multipart/form-data" )
2725 assert response .content_type == "application/vnd.ms-excel"
28- sheet = pe .load_from_memory ( 'xls' , response .data )
26+ sheet = pe .get_sheet ( file_type = 'xls' , file_content = response .data )
2927 assert sheet .to_array () == self .data
3028
3129
@@ -41,14 +39,11 @@ def setUp(self):
4139
4240 def test_book (self ):
4341 for struct_type in ["book" , "book_dict" ]:
44- io = BytesIO ()
45- book = pe .Book (self .content )
46- book .save_to_memory ('xls' , io )
47- io .seek (0 )
42+ io = pe .save_book_as (bookdict = self .content , dest_file_type = "xls" )
4843 response = self .app .post ('/exchange/%s' % struct_type ,
4944 buffered = True ,
5045 data = {"file" : (io , "test.xls" )},
5146 content_type = "multipart/form-data" )
5247 assert response .content_type == "application/vnd.ms-excel"
53- book2 = pe .load_book_from_memory ( 'xls' , response .data )
48+ book2 = pe .get_book ( file_type = 'xls' , file_content = response .data )
5449 assert book2 .to_dict () == self .content
0 commit comments