diff --git a/.gitignore b/.gitignore index 422b950..a16f3cb 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,7 @@ venv.bak/ test/log /_build/* demo/log + +# test cache data +test/.test_cache_data/* +test/.test_cache_data \ No newline at end of file diff --git a/test/test_csv.py b/test/test_csv.py new file mode 100644 index 0000000..f10d2f9 --- /dev/null +++ b/test/test_csv.py @@ -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