summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchfw <wangc_2011@hotmail.com>2016-05-03 07:47:11 (GMT)
committerchfw <wangc_2011@hotmail.com>2016-05-03 07:47:11 (GMT)
commit2734cb42f4c3a751459f555d1b2a2995cbb0ac4e (patch)
treea091503e0f9e7d46566cfff4e71829c8bb5679f1
parent823197acf91252222699b24ea94d8306745ce803 (diff)
downloadpython-pyexcel-xls-2734cb42f4c3a751459f555d1b2a2995cbb0ac4e.zip
python-pyexcel-xls-2734cb42f4c3a751459f555d1b2a2995cbb0ac4e.tar.gz
python-pyexcel-xls-2734cb42f4c3a751459f555d1b2a2995cbb0ac4e.tar.bz2
test auto_detect_int
-rw-r--r--tests/test_formatters.py56
1 files changed, 52 insertions, 4 deletions
diff --git a/tests/test_formatters.py b/tests/test_formatters.py
index 78a2ca2..7c770a5 100644
--- a/tests/test_formatters.py
+++ b/tests/test_formatters.py
@@ -1,7 +1,9 @@
-import pyexcel as pe
-import pyexcel.ext.xls
-import datetime
import os
+import datetime
+from unittest import TestCase
+from textwrap import dedent
+
+import pyexcel as pe
class TestDateFormat:
@@ -34,4 +36,50 @@ class TestDateFormat:
assert r[0,1].strftime("%H:%M:%S") == "11:11:11"
assert isinstance(r[0,2], datetime.date) == True
assert r[0,2].strftime("%d/%m/%y %H:%M:%S") == "25/12/14 11:11:11"
- os.unlink(excel_filename) \ No newline at end of file
+ os.unlink(excel_filename)
+
+
+class TestAutoDetectInt(TestCase):
+ 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)
+
+ def test_auto_detect_int(self):
+ sheet = pe.get_sheet(file_name=self.test_file)
+ expected = dedent("""
+ pyexcel_sheet1:
+ +---+---+-----+
+ | 1 | 2 | 3.1 |
+ +---+---+-----+""").strip()
+ self.assertEqual(str(sheet), expected)
+
+ def test_get_book_auto_detect_int(self):
+ book = pe.get_book(file_name=self.test_file)
+ expected = dedent("""
+ pyexcel_sheet1:
+ +---+---+-----+
+ | 1 | 2 | 3.1 |
+ +---+---+-----+""").strip()
+ self.assertEqual(str(book), expected)
+
+ def test_auto_detect_int_false(self):
+ sheet = pe.get_sheet(file_name=self.test_file, auto_detect_int=False)
+ expected = dedent("""
+ pyexcel_sheet1:
+ +-----+-----+-----+
+ | 1.0 | 2.0 | 3.1 |
+ +-----+-----+-----+""").strip()
+ self.assertEqual(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)
+ expected = dedent("""
+ pyexcel_sheet1:
+ +-----+-----+-----+
+ | 1.0 | 2.0 | 3.1 |
+ +-----+-----+-----+""").strip()
+ self.assertEqual(str(book), expected)
+
+ def tearDown(self):
+ os.unlink(self.test_file)