MCPcopy
hub / github.com/treeverse/dvc / test_list_operations

Function test_list_operations

tests/unit/test_tabular_data.py:45–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43
44
45def test_list_operations():
46 td = TabularData(["col1", "col2", "col3"])
47 td.append(["1", "2", "3"])
48
49 assert list(td) == [["1", "2", "3"]]
50 td.extend((["11", "12", "13"], ["21", "22", "23"]))
51 assert list(td) == [
52 ["1", "2", "3"],
53 ["11", "12", "13"],
54 ["21", "22", "23"],
55 ]
56 td.insert(1, ["01", "02", "03"])
57 assert list(td) == [
58 ["1", "2", "3"],
59 ["01", "02", "03"],
60 ["11", "12", "13"],
61 ["21", "22", "23"],
62 ]
63 assert td.shape == (3, 4)
64 assert len(td) == 4
65 assert td[1] == ["01", "02", "03"]
66 assert td[1:] == [
67 ["01", "02", "03"],
68 ["11", "12", "13"],
69 ["21", "22", "23"],
70 ]
71 assert td[::-1] == [
72 ["21", "22", "23"],
73 ["11", "12", "13"],
74 ["01", "02", "03"],
75 ["1", "2", "3"],
76 ]
77 del td[1]
78 assert list(td) == [
79 ["1", "2", "3"],
80 ["11", "12", "13"],
81 ["21", "22", "23"],
82 ]
83 assert td.shape == (3, 3)
84 td[1:3] = [["51", "52", "53"], ["61", "62", "63"]]
85 assert list(td) == [
86 ["1", "2", "3"],
87 ["51", "52", "53"],
88 ["61", "62", "63"],
89 ]
90 td[1] = ["41", "42", "43"]
91 assert td[1] == ["41", "42", "43"]
92
93 del td[1:3]
94 assert td.shape == (3, 1)
95
96 assert td.to_csv() == "col1,col2,col3\r\n1,2,3\r\n"
97
98
99def test_dict_like_interfaces():

Callers

nothing calls this directly

Calls 5

appendMethod · 0.95
extendMethod · 0.95
insertMethod · 0.95
to_csvMethod · 0.95
TabularDataClass · 0.90

Tested by

no test coverage detected