Skip to content

Commit 0dfe727

Browse files
committed
common tests are mobanized
1 parent 73051b6 commit 0dfe727

File tree

10 files changed

+47
-44
lines changed

10 files changed

+47
-44
lines changed

.moban.d/setup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,5 @@
1010
{%endblock%}
1111

1212
{%block additional_classifiers%}
13-
'Development Status :: 3 - Alpha',
14-
'Programming Language :: Python :: 2.6',
15-
'Programming Language :: Python :: 2.7',
16-
'Programming Language :: Python :: 3.3',
17-
'Programming Language :: Python :: 3.4',
18-
'Programming Language :: Python :: 3.5',
1913
'Programming Language :: Python :: Implementation :: PyPy'
2014
{%endblock%}

.moban.d/tests/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% extends 'tests/base.py.jj2' %}
2+
3+
{%block ods_types%}
4+
{%endblock%}

.moban.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ targets:
1515
- "tests/requirements.txt": "tests/requirements.txt"
1616
- test.sh: test.sh.jj2
1717
- test.bat: test.sh.jj2
18+
- "tests/test_filter.py": "tests/test_filter.py.jj2"
19+
- "tests/test_formatters.py": "tests/test_formatters.py.jj2"
20+
- "tests/test_stringio.py": "tests/test_stringio.py.jj2"
21+
- "tests/test_writer.py": "tests/test_writer.py.jj2"
22+
- "tests/base.py": "tests/base.py"

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ language: python
33
notifications:
44
email: false
55
python:
6-
- pypy
7-
- 2.6
8-
- 2.7
9-
- 3.3
10-
- 3.4
11-
- 3.5
126
- 3.6
7+
- 3.5
8+
- 3.4
9+
- 3.3
10+
- 2.7
11+
- 2.6
12+
- pypy
1313
matrix:
1414
include:
1515
- python: 2.7

README.rst

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ Usage
3939
As a standalone library
4040
--------------------------------------------------------------------------------
4141

42-
Write to an xls file
43-
********************************************************************************
44-
4542
.. testcode::
4643
:hide:
4744

@@ -58,6 +55,11 @@ Write to an xls file
5855
... from collections import OrderedDict
5956

6057

58+
Write to an xls file
59+
********************************************************************************
60+
61+
62+
6163
Here's the sample code to write a dictionary to an xls file:
6264

6365
.. code-block:: python
@@ -68,6 +70,7 @@ Here's the sample code to write a dictionary to an xls file:
6870
>>> data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
6971
>>> save_data("your_file.xls", data)
7072
73+
7174
Read from an xls file
7275
********************************************************************************
7376

@@ -101,6 +104,7 @@ Here's the sample code to write a dictionary to an xls file:
101104
102105
103106
107+
104108
Read from an xls from memory
105109
********************************************************************************
106110

@@ -119,6 +123,8 @@ Continue from previous example:
119123
Pagination feature
120124
********************************************************************************
121125

126+
127+
122128
Let's assume the following file is a huge xls file:
123129

124130
.. code-block:: python
@@ -175,16 +181,6 @@ No longer, explicit import is needed since pyexcel version 0.2.2. Instead,
175181
this library is auto-loaded. So if you want to read data in xls format,
176182
installing it is enough.
177183

178-
Any version under pyexcel 0.2.2, you have to keep doing the following:
179-
180-
Import it in your file to enable this plugin:
181-
182-
.. code-block:: python
183-
184-
from pyexcel.ext import xls
185-
186-
Please note only pyexcel version 0.0.4+ support this.
187-
188184

189185
Reading from an xls file
190186
********************************************************************************
@@ -194,7 +190,6 @@ Here is the sample code:
194190
.. code-block:: python
195191
196192
>>> import pyexcel as pe
197-
>>> # from pyexcel.ext import xls
198193
>>> sheet = pe.get_book(file_name="your_file.xls")
199194
>>> sheet
200195
Sheet 1:
@@ -265,6 +260,7 @@ You need to pass a StringIO instance to Writer:
265260
>>> # In reality, you might give it to your http response
266261
>>> # object for downloading
267262
263+
268264
License
269265
================================================================================
270266

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
'Programming Language :: Python',
3535
'License :: OSI Approved :: BSD License',
3636
'Intended Audience :: Developers',
37-
'Development Status :: 3 - Alpha',
3837
'Programming Language :: Python :: 2.6',
3938
'Programming Language :: Python :: 2.7',
4039
'Programming Language :: Python :: 3.3',
4140
'Programming Language :: Python :: 3.4',
4241
'Programming Language :: Python :: 3.5',
42+
'Programming Language :: Python :: 3.6',
4343
'Programming Language :: Python :: Implementation :: PyPy'
4444
]
4545

tests/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import os
1+
import os # noqa
22
import pyexcel
3+
import datetime # noqa
4+
from nose.tools import raises, eq_ # noqa
35

46

57
def create_sample_file1(file):
@@ -24,7 +26,7 @@ class PyexcelHatWriterBase:
2426
def test_series_table(self):
2527
pyexcel.save_as(adict=self.content, dest_file_name=self.testfile)
2628
r = pyexcel.get_sheet(file_name=self.testfile, name_columns_by_row=0)
27-
assert r.dict == self.content
29+
eq_(r.dict, self.content)
2830

2931

3032
class PyexcelWriterBase:

tests/test_formatters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import datetime
32
from unittest import TestCase
43
from textwrap import dedent
54

@@ -15,6 +14,7 @@ def test_reading_date_format(self):
1514
01/01/15 13:13:13
1615
0.0 0.0
1716
"""
17+
import datetime
1818
r = pe.get_sheet(file_name=os.path.join("tests", "fixtures",
1919
"date_field.xls"))
2020
assert isinstance(r[1, 0], datetime.date) is True
@@ -25,6 +25,7 @@ def test_reading_date_format(self):
2525
assert r[4, 1].strftime("%H:%M:%S") == "00:00:00"
2626

2727
def test_writing_date_format(self):
28+
import datetime
2829
excel_filename = "testdateformat.xls"
2930
data = [[datetime.date(2014, 12, 25),
3031
datetime.time(11, 11, 11),

tests/test_stringio.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import os
22
import pyexcel
3+
from nose.tools import eq_
34
from base import create_sample_file1
45

56

67
class TestStringIO:
78

89
def test_xls_stringio(self):
9-
xlsfile = "cute.xls"
10-
create_sample_file1(xlsfile)
11-
with open(xlsfile, "rb") as f:
10+
testfile = "cute.xls"
11+
create_sample_file1(testfile)
12+
with open(testfile, "rb") as f:
1213
content = f.read()
1314
r = pyexcel.get_sheet(file_type="xls", file_content=content)
1415
result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
1516
actual = list(r.enumerate())
16-
assert result == actual
17-
if os.path.exists(xlsfile):
18-
os.unlink(xlsfile)
17+
eq_(result, actual)
18+
if os.path.exists(testfile):
19+
os.unlink(testfile)
1920

2021
def test_xls_output_stringio(self):
2122
data = [
@@ -27,4 +28,4 @@ def test_xls_output_stringio(self):
2728
r = pyexcel.get_sheet(file_type="xls", file_content=io.getvalue())
2829
result = [1, 2, 3, 4, 5, 6]
2930
actual = list(r.enumerate())
30-
assert result == actual
31+
eq_(result, actual)

tests/test_writer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import os
2-
from pyexcel_xls.xls import XLSWriter, XLSBook
2+
from pyexcel_xls.xls import XLSWriter as Writer, XLSBook as Reader
33
from base import PyexcelWriterBase, PyexcelHatWriterBase
44

55

6-
class TestNativeXLWriter:
6+
class TestNativeXLSWriter:
77
def test_write_book(self):
88
self.content = {
99
"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
1010
"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
1111
"Sheet3": [[u'X', u'Y', u'Z'], [1, 4, 7], [2, 5, 8], [3, 6, 9]]
1212
}
13-
self.testfile = "xlwriter.xls"
14-
writer = XLSWriter()
13+
self.testfile = "writer.xls"
14+
writer = Writer()
1515
writer.open(self.testfile)
1616
writer.write(self.content)
1717
writer.close()
18-
reader = XLSBook()
18+
reader = Reader()
1919
reader.open(self.testfile)
2020
content = reader.read_all()
2121
reader.close()
@@ -28,7 +28,7 @@ def tearDown(self):
2828
os.unlink(self.testfile)
2929

3030

31-
class TestXLSnCSVWriter(PyexcelWriterBase):
31+
class TestxlsnCSVWriter(PyexcelWriterBase):
3232
def setUp(self):
3333
self.testfile = "test.xls"
3434
self.testfile2 = "test.csv"
@@ -40,7 +40,7 @@ def tearDown(self):
4040
os.unlink(self.testfile2)
4141

4242

43-
class TestXLSHatWriter(PyexcelHatWriterBase):
43+
class TestxlsHatWriter(PyexcelHatWriterBase):
4444
def setUp(self):
4545
self.testfile = "test.xls"
4646

0 commit comments

Comments
 (0)