Skip to content

Commit 4b774fc

Browse files
committed
💚 unit test timedelta
1 parent e309f9e commit 4b774fc

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pyexcel_xls/xlsr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ def __init__(self, file_type, **keywords):
152152
def read_sheet(self, index):
153153
native_sheet = self.content_array[index]
154154
sheet = XLSheet(
155-
native_sheet,
156-
date_mode=self.xls_book.datemode,
157-
**self._keywords
155+
native_sheet, date_mode=self.xls_book.datemode, **self._keywords
158156
)
159157
return sheet
160158

tests/test_formatters.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ def test_writing_date_format(self):
3737
datetime.date(2014, 12, 25),
3838
datetime.time(11, 11, 11),
3939
datetime.datetime(2014, 12, 25, 11, 11, 11),
40+
datetime.timedelta(
41+
days=50,
42+
seconds=27,
43+
microseconds=10,
44+
milliseconds=29000,
45+
minutes=5,
46+
hours=8,
47+
weeks=2,
48+
),
4049
]
4150
]
4251
pe.save_as(dest_file_name=excel_filename, array=data)
@@ -47,6 +56,8 @@ def test_writing_date_format(self):
4756
assert r[0, 1].strftime("%H:%M:%S") == "11:11:11"
4857
assert isinstance(r[0, 2], datetime.date) is True
4958
assert r[0, 2].strftime("%d/%m/%y %H:%M:%S") == "25/12/14 11:11:11"
59+
assert isinstance(r[0, 2], datetime.timedelta)
60+
assert r[0, 1].strftime("%H:%M:%S") == "3:30:20"
5061
os.unlink(excel_filename)
5162

5263

0 commit comments

Comments
 (0)