11import os
22import sys
3- from nose .tools import raises
4-
53import pyexcel
6-
4+ from nose . tools import raises
75from base import PyexcelMultipleSheetBase
86
97if sys .version_info [0 ] == 2 and sys .version_info [1 ] < 7 :
@@ -44,7 +42,8 @@ def _write_test_file(self, file):
4442 3,3,3,3
4543 """
4644 self .rows = 3
47- pyexcel .save_book_as (bookdict = self .content , dest_file_name = file )
45+ pyexcel .save_book_as (bookdict = self .content ,
46+ dest_file_name = file )
4847
4948 def setUp (self ):
5049 self .testfile = "multiple3.xlsx"
@@ -68,7 +67,11 @@ def test_load_a_single_sheet2(self):
6867
6968 @raises (IndexError )
7069 def test_load_a_single_sheet3 (self ):
71- pyexcel .load_book (self .testfile , sheet_index = 10000 )
70+ pyexcel .get_book (file_name = self .testfile , sheet_index = 10000 )
71+
72+ @raises (ValueError )
73+ def test_load_a_single_sheet4 (self ):
74+ pyexcel .get_book (file_name = self .testfile , sheet_name = "Not exist" )
7275
7376 def test_delete_sheets (self ):
7477 b1 = pyexcel .load_book (self .testfile )
@@ -105,7 +108,7 @@ def test_add_book1(self):
105108 b1 = pyexcel .get_book (file_name = self .testfile )
106109 b2 = pyexcel .get_book (file_name = self .testfile2 )
107110 b3 = b1 + b2
108- content = pyexcel . utils . to_dict ( b3 )
111+ content = b3 . dict
109112 sheet_names = content .keys ()
110113 assert len (sheet_names ) == 6
111114 for name in sheet_names :
@@ -118,12 +121,12 @@ def test_add_book1(self):
118121
119122 def test_add_book1_in_place (self ):
120123 """
121- test this scenario book1 += book2
124+ test this scenario: book1 += book2
122125 """
123126 b1 = pyexcel .BookReader (self .testfile )
124127 b2 = pyexcel .BookReader (self .testfile2 )
125128 b1 += b2
126- content = pyexcel . utils . to_dict ( b1 )
129+ content = b1 . dict
127130 sheet_names = content .keys ()
128131 assert len (sheet_names ) == 6
129132 for name in sheet_names :
@@ -136,12 +139,12 @@ def test_add_book1_in_place(self):
136139
137140 def test_add_book2 (self ):
138141 """
139- test this scenario book3 = book1 + sheet3
142+ test this scenario: book3 = book1 + sheet3
140143 """
141144 b1 = pyexcel .BookReader (self .testfile )
142145 b2 = pyexcel .BookReader (self .testfile2 )
143146 b3 = b1 + b2 ["Sheet3" ]
144- content = pyexcel . utils . to_dict ( b3 )
147+ content = b3 . dict
145148 sheet_names = content .keys ()
146149 assert len (sheet_names ) == 4
147150 for name in sheet_names :
@@ -154,12 +157,12 @@ def test_add_book2(self):
154157
155158 def test_add_book2_in_place (self ):
156159 """
157- test this scenario book3 = book1 + sheet3
160+ test this scenario: book3 = book1 + sheet3
158161 """
159162 b1 = pyexcel .BookReader (self .testfile )
160163 b2 = pyexcel .BookReader (self .testfile2 )
161164 b1 += b2 ["Sheet3" ]
162- content = pyexcel . utils . to_dict ( b1 )
165+ content = b1 . dict
163166 sheet_names = content .keys ()
164167 assert len (sheet_names ) == 4
165168 for name in sheet_names :
@@ -172,25 +175,25 @@ def test_add_book2_in_place(self):
172175
173176 def test_add_book3 (self ):
174177 """
175- test this scenario book3 = sheet1 + sheet2
178+ test this scenario: book3 = sheet1 + sheet2
176179 """
177180 b1 = pyexcel .BookReader (self .testfile )
178181 b2 = pyexcel .BookReader (self .testfile2 )
179182 b3 = b1 ["Sheet1" ] + b2 ["Sheet3" ]
180- content = pyexcel . utils . to_dict ( b3 )
183+ content = b3 . dict
181184 sheet_names = content .keys ()
182185 assert len (sheet_names ) == 2
183186 assert content ["Sheet3" ] == self .content ["Sheet3" ]
184187 assert content ["Sheet1" ] == self .content ["Sheet1" ]
185188
186189 def test_add_book4 (self ):
187190 """
188- test this scenario book3 = sheet1 + book
191+ test this scenario: book3 = sheet1 + book
189192 """
190193 b1 = pyexcel .BookReader (self .testfile )
191194 b2 = pyexcel .BookReader (self .testfile2 )
192195 b3 = b1 ["Sheet1" ] + b2
193- content = pyexcel . utils . to_dict ( b3 )
196+ content = b3 . dict
194197 sheet_names = content .keys ()
195198 assert len (sheet_names ) == 4
196199 for name in sheet_names :
0 commit comments