Skip to content

Commit 786e7f6

Browse files
committed
test against pyexcel v0.3.0
1 parent d8e5b35 commit 786e7f6

File tree

5 files changed

+30
-52
lines changed

5 files changed

+30
-52
lines changed

rnd_requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
https://github.com/pyexcel/pyexcel/archive/master.zip
2-
https://github.com/pyexcel/pyexcel-io/archive/master.zip
3-
https://github.com/pyexcel/pyexcel-xls/archive/master.zip
4-
https://github.com/pyexcel/pyexcel/archive/master.zip

tests/base.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import pyexcel
21
import os
2+
import pyexcel
3+
from nose.tools import eq_
34

45

56
def create_sample_file1(file):
@@ -24,8 +25,7 @@ class PyexcelHatWriterBase:
2425
def test_series_table(self):
2526
pyexcel.save_as(adict=self.content, dest_file_name=self.testfile)
2627
r = pyexcel.get_sheet(file_name=self.testfile, name_columns_by_row=0)
27-
actual = pyexcel.utils.to_dict(r)
28-
assert actual == self.content
28+
eq_(r.dict, self.content)
2929

3030

3131
class PyexcelWriterBase:
@@ -48,7 +48,7 @@ def _create_a_file(self, file):
4848
def test_write_array(self):
4949
self._create_a_file(self.testfile)
5050
r = pyexcel.get_sheet(file_name=self.testfile)
51-
actual = pyexcel.utils.to_array(r.rows())
51+
actual = list(r.rows())
5252
assert actual == self.content
5353

5454

@@ -72,36 +72,17 @@ def test_sheet_names(self):
7272

7373
def test_reading_through_sheets(self):
7474
b = pyexcel.BookReader(self.testfile)
75-
data = pyexcel.utils.to_array(b["Sheet1"].rows())
75+
data = list(b["Sheet1"].rows())
7676
expected = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]
7777
assert data == expected
78-
data = pyexcel.utils.to_array(b["Sheet2"].rows())
78+
data = list(b["Sheet2"].rows())
7979
expected = [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]
8080
assert data == expected
81-
data = pyexcel.utils.to_array(b["Sheet3"].rows())
81+
data = list(b["Sheet3"].rows())
8282
expected = [[u'X', u'Y', u'Z'], [1, 4, 7], [2, 5, 8], [3, 6, 9]]
8383
assert data == expected
8484
sheet3 = b["Sheet3"]
8585
sheet3.name_columns_by_row(0)
86-
data = pyexcel.utils.to_array(b["Sheet3"].rows())
86+
data = list(b["Sheet3"].rows())
8787
expected = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
8888
assert data == expected
89-
90-
def test_iterate_through_sheets(self):
91-
b = pyexcel.BookReader(self.testfile)
92-
for s in b:
93-
data = pyexcel.utils.to_array(s)
94-
assert self.content[s.name] == data
95-
si = pyexcel.sheets.iterators.SheetIterator(b)
96-
for s in si:
97-
data = pyexcel.utils.to_array(s)
98-
assert self.content[s.name] == data
99-
100-
def test_random_access_operator(self):
101-
r = pyexcel.BookReader(self.testfile)
102-
value = r["Sheet1"][0, 1]
103-
assert value == 1
104-
value = r["Sheet3"][0, 1]
105-
assert value == 'Y'
106-
r["Sheet3"].name_columns_by_row(0)
107-
assert r["Sheet3"][0, 1] == 4

tests/test_bug_fixes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from unittest import TestCase
1010
import pyexcel as pe
1111
from pyexcel_xlsx.xlsx import get_columns
12-
from pyexcel.sheets.matrix import _excel_column_index
12+
from pyexcel.sheets._shared import excel_column_index
1313
from nose.tools import eq_
1414

1515

@@ -46,7 +46,7 @@ def test_pyexcel_issue_4(self):
4646
]
4747
for column_name in indices:
4848
print("Testing %s" % column_name)
49-
column_index = _excel_column_index(column_name)
49+
column_index = excel_column_index(column_name)
5050
new_column_name = get_columns(column_index)
5151
print(column_index)
5252
print(column_name)

tests/test_mutliple_sheets.py renamed to tests/test_multiple_sheets.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import os
22
import sys
3-
from nose.tools import raises
4-
53
import pyexcel
6-
4+
from nose.tools import raises
75
from base import PyexcelMultipleSheetBase
86

97
if 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,7 @@ 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)
7271

7372
@raises(KeyError)
7473
def test_load_a_single_sheet4(self):
@@ -110,7 +109,7 @@ def test_add_book1(self):
110109
b1 = pyexcel.get_book(file_name=self.testfile)
111110
b2 = pyexcel.get_book(file_name=self.testfile2)
112111
b3 = b1 + b2
113-
content = pyexcel.utils.to_dict(b3)
112+
content = b3.dict
114113
sheet_names = content.keys()
115114
assert len(sheet_names) == 6
116115
for name in sheet_names:
@@ -123,12 +122,12 @@ def test_add_book1(self):
123122

124123
def test_add_book1_in_place(self):
125124
"""
126-
test this scenario book1 += book2
125+
test this scenario: book1 += book2
127126
"""
128127
b1 = pyexcel.BookReader(self.testfile)
129128
b2 = pyexcel.BookReader(self.testfile2)
130129
b1 += b2
131-
content = pyexcel.utils.to_dict(b1)
130+
content = b1.dict
132131
sheet_names = content.keys()
133132
assert len(sheet_names) == 6
134133
for name in sheet_names:
@@ -141,12 +140,12 @@ def test_add_book1_in_place(self):
141140

142141
def test_add_book2(self):
143142
"""
144-
test this scenario book3 = book1 + sheet3
143+
test this scenario: book3 = book1 + sheet3
145144
"""
146145
b1 = pyexcel.BookReader(self.testfile)
147146
b2 = pyexcel.BookReader(self.testfile2)
148147
b3 = b1 + b2["Sheet3"]
149-
content = pyexcel.utils.to_dict(b3)
148+
content = b3.dict
150149
sheet_names = content.keys()
151150
assert len(sheet_names) == 4
152151
for name in sheet_names:
@@ -159,12 +158,12 @@ def test_add_book2(self):
159158

160159
def test_add_book2_in_place(self):
161160
"""
162-
test this scenario book3 = book1 + sheet3
161+
test this scenario: book3 = book1 + sheet3
163162
"""
164163
b1 = pyexcel.BookReader(self.testfile)
165164
b2 = pyexcel.BookReader(self.testfile2)
166165
b1 += b2["Sheet3"]
167-
content = pyexcel.utils.to_dict(b1)
166+
content = b1.dict
168167
sheet_names = content.keys()
169168
assert len(sheet_names) == 4
170169
for name in sheet_names:
@@ -177,25 +176,25 @@ def test_add_book2_in_place(self):
177176

178177
def test_add_book3(self):
179178
"""
180-
test this scenario book3 = sheet1 + sheet2
179+
test this scenario: book3 = sheet1 + sheet2
181180
"""
182181
b1 = pyexcel.BookReader(self.testfile)
183182
b2 = pyexcel.BookReader(self.testfile2)
184183
b3 = b1["Sheet1"] + b2["Sheet3"]
185-
content = pyexcel.utils.to_dict(b3)
184+
content = b3.dict
186185
sheet_names = content.keys()
187186
assert len(sheet_names) == 2
188187
assert content["Sheet3"] == self.content["Sheet3"]
189188
assert content["Sheet1"] == self.content["Sheet1"]
190189

191190
def test_add_book4(self):
192191
"""
193-
test this scenario book3 = sheet1 + book
192+
test this scenario: book3 = sheet1 + book
194193
"""
195194
b1 = pyexcel.BookReader(self.testfile)
196195
b2 = pyexcel.BookReader(self.testfile2)
197196
b3 = b1["Sheet1"] + b2
198-
content = pyexcel.utils.to_dict(b3)
197+
content = b3.dict
199198
sheet_names = content.keys()
200199
assert len(sheet_names) == 4
201200
for name in sheet_names:

tests/test_stringio.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from nose.tools import eq_
23
import pyexcel
34
from base import create_sample_file1
45

@@ -12,8 +13,8 @@ def test_ods_stringio(self):
1213
content = f.read()
1314
r = pyexcel.get_sheet(file_type="xlsx", file_content=content)
1415
result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
15-
actual = pyexcel.utils.to_array(r.enumerate())
16-
assert result == actual
16+
actual = list(r.enumerate())
17+
eq_(result, actual)
1718
if os.path.exists(odsfile):
1819
os.unlink(odsfile)
1920

@@ -25,5 +26,5 @@ def test_xls_output_stringio(self):
2526
io = pyexcel.save_as(dest_file_type='xlsx', array=data)
2627
r = pyexcel.get_sheet(file_type="xlsx", file_content=io.getvalue())
2728
result = [1, 2, 3, 4, 5, 6]
28-
actual = pyexcel.utils.to_array(r.enumerate())
29-
assert result == actual
29+
actual = list(r.enumerate())
30+
eq_(result, actual)

0 commit comments

Comments
 (0)