Skip to content

Commit e7b153a

Browse files
committed
🔬 more test coverage
1 parent 04c9c84 commit e7b153a

File tree

5 files changed

+25
-32
lines changed

5 files changed

+25
-32
lines changed

.moban.d/custom_README.rst.jj2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{%extends 'README.rst.jj2' %}
22

33
{%block description%}
4-
**{{name}}** is a tiny wrapper library to write data in xlsx and xlsm fromat using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.
4+
**{{name}}** is a tiny wrapper library to write data in xlsx and xlsm format
5+
using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.
56
{%endblock%}
67

78

@@ -61,3 +62,6 @@ Let's assume we have data as the following.
6162

6263
{%block read_from_memory_via_pyexcel %}
6364
{%endblock%}
65+
66+
{% block pyexcel_write_to_memory%}
67+
{% endblock %}

README.rst

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ pyexcel-libxlsxw - Let you focus on data, instead of xlsx format
3333
.. image:: https://readthedocs.org/projects/pyexcel-libxlsxw/badge/?version=latest
3434
:target: http://pyexcel-libxlsxw.readthedocs.org/en/latest/
3535

36-
**pyexcel-libxlsxw** is a tiny wrapper library to write data in xlsx and xlsm fromat using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.
36+
**pyexcel-libxlsxw** is a tiny wrapper library to write data in xlsx and xlsm format
37+
using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.
3738

3839
Support the project
3940
================================================================================
@@ -198,23 +199,6 @@ Here is the sample code:
198199
>>> sheet.save_as("another_file.xlsx")
199200
200201
201-
Writing to a StringIO instance
202-
********************************************************************************
203-
204-
You need to pass a StringIO instance to Writer:
205-
206-
.. code-block:: python
207-
208-
>>> data = [
209-
... [1, 2, 3],
210-
... [4, 5, 6]
211-
... ]
212-
>>> io = StringIO()
213-
>>> sheet = pe.Sheet(data)
214-
>>> io = sheet.save_to_memory("xlsx", io)
215-
>>> # then do something with io
216-
>>> # In reality, you might give it to your http response
217-
>>> # object for downloading
218202
219203
220204
License

tests/base.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55
from nose.tools import eq_
66

77

8-
def create_sample_file1(file):
9-
data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
10-
table = []
11-
table.append(data[:4])
12-
table.append(data[4:8])
13-
table.append(data[8:12])
14-
pyexcel.save_as(
15-
array=table, dest_file_name=file, library="pyexcel-libxlsxw"
16-
)
17-
18-
198
class PyexcelHatWriterBase:
209
"""
2110
Abstract functional test for hat writers

tests/test_stringio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pyexcel
22

3-
43
from nose.tools import eq_
54

65

tests/test_writer.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from datetime import date, time, datetime
23

34
from base import PyexcelWriterBase, PyexcelHatWriterBase
45
from pyexcel_xls import get_data
@@ -8,13 +9,29 @@
89

910

1011
class TestNativeXLWriter:
12+
def setUp(self):
13+
self.testfile = "xlwriter.xlsx"
14+
1115
def test_write_book(self):
1216
self.content = {
1317
"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
1418
"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
1519
"Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]],
1620
}
17-
self.testfile = "xlwriter.xlsx"
21+
writer = xlsx.XLSXWriter(self.testfile, "xlsx")
22+
writer.write(self.content)
23+
writer.close()
24+
content = get_data(self.testfile)
25+
for key in content.keys():
26+
content[key] = list(content[key])
27+
eq_(content, self.content)
28+
29+
def test_write_dates(self):
30+
self.content = {
31+
"date": [[date(2020, 10, 11)]],
32+
"time": [[time(11, 22, 11)]],
33+
"datetime": [[datetime(2020, 11, 11, 12, 12, 12)]],
34+
}
1835
writer = xlsx.XLSXWriter(self.testfile, "xlsx")
1936
writer.write(self.content)
2037
writer.close()

0 commit comments

Comments
 (0)