common tests are mobanized
This commit is contained in:
parent
d56d325b42
commit
45c6f347c0
|
@ -0,0 +1,4 @@
|
|||
{% extends 'tests/test_formatters.py.jj2' %}
|
||||
|
||||
{% block test_date_format %}
|
||||
{% endblock %}
|
|
@ -15,3 +15,8 @@ targets:
|
|||
- "tests/requirements.txt": "tests/requirements.txt"
|
||||
- test.sh: test.sh.jj2
|
||||
- test.bat: test.sh.jj2
|
||||
- "tests/test_filter.py": "tests/test_filter.py.jj2"
|
||||
- "tests/test_formatters.py": "tests/test_formatters.py"
|
||||
- "tests/test_stringio.py": "tests/test_stringio.py.jj2"
|
||||
- "tests/test_writer.py": "tests/test_writer.py.jj2"
|
||||
- "tests/base.py": "tests/base.py.jj2"
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
import os
|
||||
from nose.tools import eq_
|
||||
import pyexcel
|
||||
from nose.tools import eq_
|
||||
from base import create_sample_file1
|
||||
|
||||
|
||||
class TestStringIO:
|
||||
|
||||
def test_ods_stringio(self):
|
||||
odsfile = "cute.ods"
|
||||
create_sample_file1(odsfile)
|
||||
with open(odsfile, "rb") as f:
|
||||
testfile = "cute.ods"
|
||||
create_sample_file1(testfile)
|
||||
with open(testfile, "rb") as f:
|
||||
content = f.read()
|
||||
r = pyexcel.get_sheet(file_type="ods", file_content=content)
|
||||
result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
|
||||
actual = list(r.enumerate())
|
||||
eq_(result, actual)
|
||||
if os.path.exists(odsfile):
|
||||
os.unlink(odsfile)
|
||||
if os.path.exists(testfile):
|
||||
os.unlink(testfile)
|
||||
|
||||
def test_xls_output_stringio(self):
|
||||
def test_ods_output_stringio(self):
|
||||
data = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6]
|
||||
]
|
||||
io = pyexcel.save_as(dest_file_type='ods', array=data)
|
||||
io = pyexcel.save_as(dest_file_type="ods",
|
||||
array=data)
|
||||
r = pyexcel.get_sheet(file_type="ods", file_content=io.getvalue())
|
||||
result = [1, 2, 3, 4, 5, 6]
|
||||
actual = list(r.enumerate())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from pyexcel_ods import ods
|
||||
from pyexcel_ods.ods import ODSWriter as Writer, ODSBook as Reader
|
||||
from base import PyexcelWriterBase, PyexcelHatWriterBase
|
||||
|
||||
|
||||
|
@ -10,14 +10,15 @@ class TestNativeODSWriter:
|
|||
"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 = "odswriter.ods"
|
||||
writer = ods.ODSWriter()
|
||||
self.testfile = "writer.ods"
|
||||
writer = Writer()
|
||||
writer.open(self.testfile)
|
||||
writer.write(self.content)
|
||||
writer.close()
|
||||
reader = ods.ODSBook()
|
||||
reader = Reader()
|
||||
reader.open(self.testfile)
|
||||
content = reader.read_all()
|
||||
reader.close()
|
||||
for key in content.keys():
|
||||
content[key] = list(content[key])
|
||||
assert content == self.content
|
||||
|
@ -27,9 +28,9 @@ class TestNativeODSWriter:
|
|||
os.unlink(self.testfile)
|
||||
|
||||
|
||||
class TestODSnCSVWriter(PyexcelWriterBase):
|
||||
class TestodsnCSVWriter(PyexcelWriterBase):
|
||||
def setUp(self):
|
||||
self.testfile = "testods.ods"
|
||||
self.testfile = "test.ods"
|
||||
self.testfile2 = "test.csv"
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -39,9 +40,9 @@ class TestODSnCSVWriter(PyexcelWriterBase):
|
|||
os.unlink(self.testfile2)
|
||||
|
||||
|
||||
class TestODSHatWriter(PyexcelHatWriterBase):
|
||||
class TestodsHatWriter(PyexcelHatWriterBase):
|
||||
def setUp(self):
|
||||
self.testfile = "testhat.ods"
|
||||
self.testfile = "test.ods"
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(self.testfile):
|
||||
|
|
Loading…
Reference in New Issue