Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2018.6.27 v1.0.14, add fish_csv unittest #72
- Loading branch information
Chunying Jia
committed
Jun 27, 2018
1 parent
0a4d3a8
commit 84d470f
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,7 @@ venv.bak/ | |
test/log | ||
/_build/* | ||
demo/log | ||
|
||
# test cache data | ||
test/.test_cache_data/* | ||
test/.test_cache_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import shutil | ||
from fishbase.fish_csv import csv_file_to_list | ||
|
||
|
||
# 2018.6.27 v1.0.14 #73 create by Jia ChunYing | ||
class TestCsv(object): | ||
|
||
# 测试 csv_file_to_list() tc | ||
def test_csv(self): | ||
# 创建csv测试文件 | ||
csv_file_name = '.test_cache_data/test_file.csv' | ||
if os.path.isfile(csv_file_name): | ||
os.remove(csv_file_name) | ||
if not os.path.exists(os.path.dirname(csv_file_name)): | ||
os.makedirs(os.path.dirname(csv_file_name)) | ||
csv_content = "a,b\n1,2" | ||
with open(csv_file_name, 'w') as f: | ||
f.write(csv_content) | ||
f.close() | ||
result = csv_file_to_list(csv_file_name) | ||
shutil.rmtree(os.path.dirname(csv_file_name)) | ||
assert len(result) == 2 | ||
assert len(result[0]) == 2 | ||
assert len(result[1]) == 2 |