MCPcopy Create free account
hub / github.com/cdgriffith/Box / test_to_csv

Method test_to_csv

test/test_box_list.py:134–148  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

132 assert isinstance(bl[0], BoxList)
133
134 def test_to_csv(self):
135 data = BoxList(
136 [
137 {"Number": 1, "Name": "Chris", "Country": "US"},
138 {"Number": 2, "Name": "Sam", "Country": "US"},
139 {"Number": 3, "Name": "Jess", "Country": "US"},
140 {"Number": 4, "Name": "Frank", "Country": "UK"},
141 {"Number": 5, "Name": "Demo", "Country": "CA"},
142 ]
143 )
144
145 file = Path(tmp_dir, "csv_file.csv")
146 data.to_csv(filename=file)
147 assert file.read_text().startswith("Number,Name,Country\n1,Chris,US")
148 assert data.to_csv().endswith("2,Sam,US\r\n3,Jess,US\r\n4,Frank,UK\r\n5,Demo,CA\r\n")
149
150 def test_from_csv(self):
151 bl = BoxList.from_csv(filename=Path(test_root, "data", "csv_file.csv"))

Callers

nothing calls this directly

Calls 2

to_csvMethod · 0.95
BoxListClass · 0.90

Tested by

no test coverage detected