diff --git a/test/test_csv_writer.py b/test/test_csv_writer.py index 245229f9..b8c4f50e 100644 --- a/test/test_csv_writer.py +++ b/test/test_csv_writer.py @@ -32,80 +32,71 @@ Data = collections.namedtuple("Data", "col_delim header value expected") normal_test_data_list = [ - Data( - col_delim=",", - header=header_list, - value=value_matrix, - expected=""""a","b","c","dd","e" + Data(col_delim=",", + header=header_list, + value=value_matrix, + expected=""""a","b","c","dd","e" 1,123.1,"a",1,1 2,2.2,"bb",2.2,2.2 3,3.3,"ccc",3,"cccc" """), - Data( - col_delim=",", - header=header_list, - value=[], - expected=""""a","b","c","dd","e" + Data(col_delim=",", + header=header_list, + value=[], + expected=""""a","b","c","dd","e" """), - Data( - col_delim=",", - header=[], - value=value_matrix, - expected="""1,123.1,"a",1,1 + Data(col_delim=",", + header=[], + value=value_matrix, + expected="""1,123.1,"a",1,1 2,2.2,"bb",2.2,2.2 3,3.3,"ccc",3,"cccc" """), - Data( - col_delim="\t", - header=None, - value=value_matrix, - expected="""1\t123.1\t"a"\t1\t1 + Data(col_delim="\t", + header=None, + value=value_matrix, + expected="""1\t123.1\t"a"\t1\t1 2\t2.2\t"bb"\t2.2\t2.2 3\t3.3\t"ccc"\t3\t"cccc" """), - Data( - col_delim=",", - header=header_list, - value=value_matrix_with_none, - expected=""""a","b","c","dd","e" + Data(col_delim=",", + header=header_list, + value=value_matrix_with_none, + expected=""""a","b","c","dd","e" 1,,"a",1, ,2.2,,2.2,2.2 3,3.3,"ccc",,"cccc" ,,,, """), - Data( - col_delim=",", - header=mix_header_list, - value=mix_value_matrix, - expected=""""i","f","c","if","ifc","bool","inf","nan","mix_num","time" + Data(col_delim=",", + header=mix_header_list, + value=mix_value_matrix, + expected=""""i","f","c","if","ifc","bool","inf","nan","mix_num","time" 1,1.1,"aa",1,1,True,Infinity,NaN,1,"2017-01-01T00:00:00" 2,2.2,"bbb",2.2,2.2,False,Infinity,NaN,Infinity,"2017-01-02 03:04:05+09:00" 3,3.33,"cccc",-3,"ccc",True,Infinity,NaN,NaN,"2017-01-01T00:00:00" """), - Data( - col_delim=",", - header=float_header_list, - value=float_value_matrix, - expected=""""a","b","c" + Data(col_delim=",", + header=float_header_list, + value=float_value_matrix, + expected=""""a","b","c" 0.01,0.00125,0 1,99.9,0.01 1.2,999999.123,0.001 """), - Data( - col_delim=",", - header=["a\nb", "c\n\nd", "e\r\nf"], - value=[["v1\nv1", "v2\n\nv2", "v3\r\nv3"]], - expected=""""a b","c d","e f" + Data(col_delim=",", + header=["a\nb", "c\n\nd", "e\r\nf"], + value=[["v1\nv1", "v2\n\nv2", "v3\r\nv3"]], + expected=""""a b","c d","e f" "v1 v1","v2 v2","v3 v3" """), ] exception_test_data_list = [ - Data( - col_delim=",", - header=header, - value=value, - expected=ptw.EmptyTableDataError) + Data(col_delim=",", + header=header, + value=value, + expected=ptw.EmptyTableDataError) for header, value in itertools.product([None, [], ""], [None, [], ""]) ] @@ -145,11 +136,6 @@ def test_normal_from_text(self, capsys): assert writer.table_name == "csv1" assert writer.header_list == ["a", "b", "c", "dd", "e"] - assert writer.value_matrix == [ - [1, Decimal('1.1'), 'a', Decimal('1.0'), ''], - [2, Decimal('2.2'), '', Decimal('2.2'), Decimal('2.2')], - [3, Decimal('3.3'), 'ccc', '', 'cc\ncc'] - ] print("[expected]\n{}".format(self.__CSV_EXPECTED)) print("[actual]\n{}".format(out)) @@ -169,11 +155,6 @@ def test_normal_from_file(self, capsys, tmpdir): assert writer.table_name == "test_data" assert writer.header_list == ["a", "b", "c", "dd", "e"] - assert writer.value_matrix == [ - [1, Decimal('1.1'), 'a', Decimal('1'), ''], - [2, Decimal('2.2'), '', Decimal('2.2'), Decimal('2.2')], - [3, Decimal('3.3'), 'ccc', '', 'cc\ncc'] - ] print("[expected]\n{}".format(self.__CSV_EXPECTED)) print("[actual]\n{}".format(out)) diff --git a/test/test_markdown_writer.py b/test/test_markdown_writer.py index 663cd36e..26d7d751 100644 --- a/test/test_markdown_writer.py +++ b/test/test_markdown_writer.py @@ -12,9 +12,9 @@ from decimal import Decimal import pytest +from tabledata import TableData import pytablewriter as ptw -from tabledata import TableData from .data import ( header_list, @@ -321,28 +321,6 @@ def test_normal(self, capsys): assert out == "\n" -class Test_MarkdownTableWriter_set_table_data(object): - - def test_normal(self): - writer = table_writer_class() - writer.from_tabledata(TableData( - "tmp", - ["attr_a", "attr_b", "attr_c"], - [ - ["1", "4", "a"], - ["2", "2.1", "bb"], - ["3", "120.9", "ccc"], - ])) - - assert writer.table_name == "tmp" - assert writer.header_list == ["attr_a", "attr_b", "attr_c"] - assert writer.value_matrix == [ - [1, 4, "a"], - [2, Decimal("2.1"), "bb"], - [3, Decimal("120.9"), "ccc"], - ] - - class Test_MarkdownTableWriter_write_table(object): @pytest.mark.parametrize( diff --git a/test/test_sqlite_writer.py b/test/test_sqlite_writer.py index c5bca300..912cdf98 100644 --- a/test/test_sqlite_writer.py +++ b/test/test_sqlite_writer.py @@ -12,10 +12,10 @@ from decimal import Decimal import pytest +from tabledata import TableData import pytablereader as ptr import pytablewriter as ptw -from tabledata import TableData from .data import ( header_list, @@ -57,7 +57,7 @@ [ [ 1, "1.1", 'aa', 1, 1, 1, inf, - nan, 1, '2017-01-01T00:00:00', + nan, 1, '2017-01-01 00:00:00', ], [ 2, "2.2", 'bbb', "2.2", "2.2", 0, inf, nan, @@ -65,7 +65,7 @@ ], [ 3, "3.33", 'cccc', -3, 'ccc', 1, inf, - nan, nan, '2017-01-01T00:00:00', + nan, nan, '2017-01-01 00:00:00', ], ])), Data(