Skip to content

Commit

Permalink
🔬 more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Oct 16, 2020
1 parent 04c9c84 commit e7b153a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 32 deletions.
6 changes: 5 additions & 1 deletion .moban.d/custom_README.rst.jj2
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{%extends 'README.rst.jj2' %}

{%block description%}
**{{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>`__.
**{{name}}** is a tiny wrapper library to write data in xlsx and xlsm format
using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.
{%endblock%}


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

{%block read_from_memory_via_pyexcel %}
{%endblock%}

{% block pyexcel_write_to_memory%}
{% endblock %}
20 changes: 2 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ pyexcel-libxlsxw - Let you focus on data, instead of xlsx format
.. image:: https://readthedocs.org/projects/pyexcel-libxlsxw/badge/?version=latest
:target: http://pyexcel-libxlsxw.readthedocs.org/en/latest/

**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>`__.
**pyexcel-libxlsxw** is a tiny wrapper library to write data in xlsx and xlsm format
using libxlsxwriter. You are likely to use it with `pyexcel <https://github.com/pyexcel/pyexcel>`__.

Support the project
================================================================================
Expand Down Expand Up @@ -198,23 +199,6 @@ Here is the sample code:
>>> sheet.save_as("another_file.xlsx")
Writing to a StringIO instance
********************************************************************************

You need to pass a StringIO instance to Writer:

.. code-block:: python
>>> data = [
... [1, 2, 3],
... [4, 5, 6]
... ]
>>> io = StringIO()
>>> sheet = pe.Sheet(data)
>>> io = sheet.save_to_memory("xlsx", io)
>>> # then do something with io
>>> # In reality, you might give it to your http response
>>> # object for downloading
License
Expand Down
11 changes: 0 additions & 11 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
from nose.tools import eq_


def create_sample_file1(file):
data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
table = []
table.append(data[:4])
table.append(data[4:8])
table.append(data[8:12])
pyexcel.save_as(
array=table, dest_file_name=file, library="pyexcel-libxlsxw"
)


class PyexcelHatWriterBase:
"""
Abstract functional test for hat writers
Expand Down
1 change: 0 additions & 1 deletion tests/test_stringio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pyexcel


from nose.tools import eq_


Expand Down
19 changes: 18 additions & 1 deletion tests/test_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from datetime import date, time, datetime

from base import PyexcelWriterBase, PyexcelHatWriterBase
from pyexcel_xls import get_data
Expand All @@ -8,13 +9,29 @@


class TestNativeXLWriter:
def setUp(self):
self.testfile = "xlwriter.xlsx"

def test_write_book(self):
self.content = {
"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
"Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]],
}
self.testfile = "xlwriter.xlsx"
writer = xlsx.XLSXWriter(self.testfile, "xlsx")
writer.write(self.content)
writer.close()
content = get_data(self.testfile)
for key in content.keys():
content[key] = list(content[key])
eq_(content, self.content)

def test_write_dates(self):
self.content = {
"date": [[date(2020, 10, 11)]],
"time": [[time(11, 22, 11)]],
"datetime": [[datetime(2020, 11, 11, 12, 12, 12)]],
}
writer = xlsx.XLSXWriter(self.testfile, "xlsx")
writer.write(self.content)
writer.close()
Expand Down

0 comments on commit e7b153a

Please sign in to comment.