File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,15 @@ def compare_rows_helper(expected: List[dict], actual: List[dict]):
2222 actual
2323 ), f"Unequal row counts: { len (expected )} != { len (actual )} "
2424 errors = []
25- for l , r in zip ( expected , actual ):
26- l_cols , r_cols = set ( l . keys ()), set ( r . keys ())
27- assert l_cols == r_cols , f"Unequal sets of columns: { l_cols } != { r_cols } "
28- for col in l_cols :
29- l_val , r_val = l [ col ], r [ col ]
30- if col . startswith ( "date" ):
31- l_val , r_val = l_val [: 10 ], r_val [: 10 ]
32- if l_val != r_val and not ( l_val is None and r_val == "" ):
33- errors .append (f"{ col } : { l_val } != { r_val } " )
25+ for k in expected [ 0 ]. keys ( ):
26+ if k . startswith ( "date" ):
27+ exp = set ([ e [ k ][: 10 ] for e in expected ])
28+ act = set ([ a [ k ][: 10 ] for a in actual ])
29+ else :
30+ exp = set ([ e [ k ] for e in expected ])
31+ act = set ([ a [ k ] for a in actual ])
32+ if exp ^ act != set ( ):
33+ errors .append (f"Unequal value sets : { exp } , { act } " )
3434
3535 error_str = "\n " .join (errors )
3636 assert not errors , f"Failed with the following unequal columns:\n { error_str } "
Original file line number Diff line number Diff line change @@ -56,5 +56,6 @@ def test_read_columns(with_initial_test_data):
5656 second_commit = update_test_data (dolt )
5757 first_write = read_columns (dolt , TEST_TABLE , first_commit )
5858 compare_rows_helper (columns_to_rows (first_write ), TEST_DATA_INITIAL )
59- second_write = read_columns (dolt , TEST_TABLE , second_commit )
60- compare_rows_helper (columns_to_rows (second_write ), TEST_DATA_COMBINED )
59+ second_write = columns_to_rows (read_columns (dolt , TEST_TABLE , second_commit ))
60+ sorted (second_write , key = lambda x : int (x ["id" ]))
61+ compare_rows_helper (second_write , TEST_DATA_COMBINED )
You can’t perform that action at this time.
0 commit comments