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

Method test_to_csv

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

Source from the content-addressed store, hash-verified

366 assert isinstance(bl[0], BoxList)
367
368 def test_to_csv(self):
369 data = BoxList(
370 [
371 {"Number": 1, "Name": "Chris", "Country": "US"},
372 {"Number": 2, "Name": "Sam", "Country": "US"},
373 {"Number": 3, "Name": "Jess", "Country": "US"},
374 {"Number": 4, "Name": "Frank", "Country": "UK"},
375 {"Number": 5, "Name": "Demo", "Country": "CA"},
376 ]
377 )
378
379 file = Path(tmp_dir, "csv_file.csv")
380 data.to_csv(filename=file)
381 assert file.read_text().startswith("Number,Name,Country\n1,Chris,US")
382 assert data.to_csv().endswith("2,Sam,US\r\n3,Jess,US\r\n4,Frank,UK\r\n5,Demo,CA\r\n")
383
384 def test_from_csv(self):
385 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