def writes_features_in_csv(self): features = [ ("pending", 1, "alice"), ("pending", 2, "bob"), ("active", 8, "carol"), ("active", 9, "dave"), ("active", 10, "eve")] output = StringIO() write_table_as_csv(features, output, dialect="excel") csv_lines = output.getvalue().splitlines() assert_that(csv_lines, equal_to([ "pending,1,alice", "pending,2,bob", "active,8,carol", "active,9,dave", "active,10,eve"]))
def test_formats_empty_list_as_empty_string(self): output = StringIO() write_table_as_csv([], output) assert_that(output.getvalue(), equal_to(""))