|
1 | 1 | import os
|
| 2 | +from datetime import date, time, datetime |
2 | 3 |
|
3 | 4 | from base import PyexcelWriterBase, PyexcelHatWriterBase
|
4 | 5 | from pyexcel_xls import get_data
|
|
8 | 9 |
|
9 | 10 |
|
10 | 11 | class TestNativeXLWriter:
|
| 12 | + def setUp(self): |
| 13 | + self.testfile = "xlwriter.xlsx" |
| 14 | + |
11 | 15 | def test_write_book(self):
|
12 | 16 | self.content = {
|
13 | 17 | "Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
|
14 | 18 | "Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
|
15 | 19 | "Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]],
|
16 | 20 | }
|
17 |
| - self.testfile = "xlwriter.xlsx" |
| 21 | + writer = xlsx.XLSXWriter(self.testfile, "xlsx") |
| 22 | + writer.write(self.content) |
| 23 | + writer.close() |
| 24 | + content = get_data(self.testfile) |
| 25 | + for key in content.keys(): |
| 26 | + content[key] = list(content[key]) |
| 27 | + eq_(content, self.content) |
| 28 | + |
| 29 | + def test_write_dates(self): |
| 30 | + self.content = { |
| 31 | + "date": [[date(2020, 10, 11)]], |
| 32 | + "time": [[time(11, 22, 11)]], |
| 33 | + "datetime": [[datetime(2020, 11, 11, 12, 12, 12)]], |
| 34 | + } |
18 | 35 | writer = xlsx.XLSXWriter(self.testfile, "xlsx")
|
19 | 36 | writer.write(self.content)
|
20 | 37 | writer.close()
|
|
0 commit comments