8000 test pathlib feature #263 · pyexcel/pyexcel@7e1ef35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e1ef35

Browse files
committed
test pathlib feature #263
1 parent 53e51c0 commit 7e1ef35

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/test_fileio.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from textwrap import dedent
3+
from pathlib import Path
34

45
import pyexcel as pe
56

@@ -23,6 +24,23 @@ def test_write_texttable():
2324
os.unlink(test_file)
2425

2526

27+
def test_write_texttable_using_pathlib():
28+
content = [[1, 2]]
29+
test_file = "test.texttable"
30+
expected = dedent(
31+
"""
32+
pyexcel_sheet1:
33+
+---+---+
34+
| 1 | 2 |
35+
+---+---+""",
36+
).strip("\n")
37+
pe.save_as(array=content, dest_file_name=Path(test_file))
38+
with open(test_file, "r", encoding="utf-8") as f:
39+
written = f.read()
40+
eq_(written, expected)
41+
os.unlink(test_file)
42+
43+
2644
def test_write_texttable_book():
2745
content = {"Sheet": [[1, 2]]}
2846
test_file = "test.texttable"
@@ -38,3 +56,20 @@ def test_write_texttable_book():
3856
written = f.read()
3957
eq_(written, expected)
4058
os.unlink(test_file)
59+
60+
61+
def test_write_texttable_book_using_pathlib():
62+
content = {"Sheet": [[1, 2]]}
63+
test_file = "test.texttable"
64+
expected = dedent(
65+
"""
66+
Sheet:
67+
+---+---+
68+
| 1 | 2 |
69+
+---+---+""",
70+
).strip("\n")
71+
pe.save_book_as(bookdict=content, dest_file_name=Path(test_file))
72+
with open(test_file, "r", encoding="utf-8") as f:
73+
written = f.read()
74+
eq_(written, expected)
75+
os.unlink(test_file)

0 commit comments

Comments
 (0)
0