test auto_detect_int
This commit is contained in:
parent
823197acf9
commit
2734cb42f4
|
@ -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)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue