11import os
2+ import sys
3+ from unittest import TestCase
24import pyexcel as pe
3- from pyexcel .ext import webio
4- from pyexcel .ext import xls
5+ import pyexcel_webio as webio
56from db import Session , Base , Signature , Signature2 , engine
6- import sys
77if sys .version_info [0 ] == 2 and sys .version_info [1 ] < 7 :
88 from ordereddict import OrderedDict
99else :
@@ -166,28 +166,28 @@ def test_wrong_file_tuple_returned(self):
166166 myinput .get_sheet (field_name = ('xls' , None ))
167167
168168
169- class TestExcelInputOnBook :
169+ class TestExcelInputOnBook ( TestCase ) :
170170 def setUp (self ):
171171 self .data = [['X' , 'Y' , 'Z' ], [1 , 2 , 3 ], [4 , 5 , 6 ]]
172172 self .data1 = [['A' , 'B' , 'C' ], [1 , 2 , 3 ], [4 , 5 , 6 ]]
173173 mydict = OrderedDict ()
174- mydict .update ({'sheet1 ' : self .data })
175- mydict .update ({'sheet2 ' : self .data1 })
174+ mydict .update ({'signature ' : self .data })
175+ mydict .update ({'signature2 ' : self .data1 })
176176 book = pe .Book (mydict )
177177 self .testfile = "testfile.xls"
178178 book .save_as (self .testfile )
179179
180180 def test_get_book (self ):
181181 myinput = TestInput ()
182182 result = myinput .get_book (file_name = self .testfile )
183- assert result ["sheet1 " ].to_array () == self .data
184- assert result ["sheet2 " ].to_array () == self .data1
183+ assert result ["signature " ].to_array () == self .data
184+ assert result ["signature2 " ].to_array () == self .data1
185185
186186 def test_get_book_dict (self ):
187187 myinput = TestInput ()
188188 result = myinput .get_book_dict (file_name = self .testfile )
189- assert result ["sheet1 " ] == self .data
190- assert result ["sheet2 " ] == self .data1
189+ assert result ["signature " ] == self .data
190+ assert result ["signature2 " ] == self .data1
191191
192192 def test_save_to_database (self ):
193193 Base .metadata .drop_all (engine )
@@ -196,7 +196,7 @@ def test_save_to_database(self):
196196 myinput = TestInput ()
197197 myinput .save_book_to_database (file_name = self .testfile , session = self .session , tables = [Signature , Signature2 ])
198198 array = pe .get_array (session = self .session , table = Signature )
199- assert array == self .data
199+ self . assertEqual ( array , self .data )
200200 array = pe .get_array (session = self .session , table = Signature2 )
201201 assert array == self .data1
202202 self .session .close ()
0 commit comments