🤝 synchronize with pyexcel-commons

This commit is contained in:
chfw 2017-12-08 22:44:57 +00:00
parent 4cea637cce
commit 7dad0f3261
3 changed files with 23 additions and 19 deletions

View File

@ -10,11 +10,9 @@ extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
intersphinx_mapping = {
'pyexcel': ('http://pyexcel.readthedocs.io/en/latest/', None),
}
spelling_word_list_filename = 'spelling_wordlist.txt'
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
@ -22,7 +20,7 @@ master_doc = 'index'
project = u'pyexcel-xls'
copyright = u'2015-2017 Onni Software Ltd.'
version = '0.5.4'
release = '0.5.4'
release = '0.5.5'
exclude_patterns = []
pygments_style = 'sphinx'
html_theme = 'default'

View File

@ -1,6 +1,6 @@
import os
from unittest import TestCase
from textwrap import dedent
from nose.tools import eq_
import pyexcel as pe
@ -10,7 +10,7 @@ class TestDateFormat:
"""
date time
25/12/14 11:11:11
25/12/14 12:11:11
25/12/14 12:12:12
01/01/15 13:13:13
0.0 0.0
"""
@ -18,8 +18,8 @@ class TestDateFormat:
r = pe.get_sheet(file_name=os.path.join("tests", "fixtures",
"date_field.xls"),
library='pyexcel-xls')
assert isinstance(r[1, 0], datetime.date) is True
assert r[1, 0].strftime("%d/%m/%y") == "25/12/14"
assert isinstance(r[1, 0], datetime.date)
eq_(r[1, 0].strftime("%d/%m/%y"), "25/12/14")
assert isinstance(r[1, 1], datetime.time) is True
assert r[1, 1].strftime("%H:%M:%S") == "11:11:11"
assert r[4, 0].strftime("%d/%m/%Y") == "01/01/1900"
@ -42,47 +42,51 @@ class TestDateFormat:
os.unlink(excel_filename)
class TestAutoDetectInt(TestCase):
class TestAutoDetectInt:
def setUp(self):
self.content = [[1, 2, 3.1]]
self.test_file = "test_auto_detect_init.xls"
pe.save_as(array=self.content, dest_file_name=self.test_file)
pe.save_as(
array=self.content, dest_file_name=self.test_file
)
def test_auto_detect_int(self):
sheet = pe.get_sheet(file_name=self.test_file)
sheet = pe.get_sheet(file_name=self.test_file, library="pyexcel-xls")
expected = dedent("""
pyexcel_sheet1:
+---+---+-----+
| 1 | 2 | 3.1 |
+---+---+-----+""").strip()
self.assertEqual(str(sheet), expected)
eq_(str(sheet), expected)
def test_get_book_auto_detect_int(self):
book = pe.get_book(file_name=self.test_file)
book = pe.get_book(file_name=self.test_file, library="pyexcel-xls")
expected = dedent("""
pyexcel_sheet1:
+---+---+-----+
| 1 | 2 | 3.1 |
+---+---+-----+""").strip()
self.assertEqual(str(book), expected)
eq_(str(book), expected)
def test_auto_detect_int_false(self):
sheet = pe.get_sheet(file_name=self.test_file, auto_detect_int=False)
sheet = pe.get_sheet(file_name=self.test_file, auto_detect_int=False,
library="pyexcel-xls")
expected = dedent("""
pyexcel_sheet1:
+-----+-----+-----+
| 1.0 | 2.0 | 3.1 |
+-----+-----+-----+""").strip()
self.assertEqual(str(sheet), expected)
eq_(str(sheet), expected)
def test_get_book_auto_detect_int_false(self):
book = pe.get_book(file_name=self.test_file, auto_detect_int=False)
book = pe.get_book(file_name=self.test_file, auto_detect_int=False,
library="pyexcel-xls")
expected = dedent("""
pyexcel_sheet1:
+-----+-----+-----+
| 1.0 | 2.0 | 3.1 |
+-----+-----+-----+""").strip()
self.assertEqual(str(book), expected)
eq_(str(book), expected)
def tearDown(self):
os.unlink(self.test_file)

View File

@ -11,7 +11,8 @@ class TestStringIO:
create_sample_file1(testfile)
with open(testfile, "rb") as f:
content = f.read()
r = pyexcel.get_sheet(file_type="xls", file_content=content)
r = pyexcel.get_sheet(file_type="xls", file_content=content,
library="pyexcel-xls")
result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
actual = list(r.enumerate())
eq_(result, actual)
@ -25,7 +26,8 @@ class TestStringIO:
]
io = pyexcel.save_as(dest_file_type="xls",
array=data)
r = pyexcel.get_sheet(file_type="xls", file_content=io.getvalue())
r = pyexcel.get_sheet(file_type="xls", file_content=io.getvalue(),
library="pyexcel-xls")
result = [1, 2, 3, 4, 5, 6]
actual = list(r.enumerate())
eq_(result, actual)