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

Function test_row_from_dict

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

Source from the content-addressed store, hash-verified

171
172
173def test_row_from_dict():
174 td = TabularData(["col1", "col2"])
175 td.row_from_dict({"col3": "value3", "col4": "value4"})
176 assert td.keys() == ["col1", "col2", "col3", "col4"]
177 assert dict(td.items()) == {
178 "col1": [""],
179 "col2": [""],
180 "col3": ["value3"],
181 "col4": ["value4"],
182 }
183 td.row_from_dict({"col3": "value3", "col5": "value5", "col6": "value6"})
184 assert td.keys() == ["col1", "col2", "col3", "col4", "col5", "col6"]
185 assert dict(td.items()) == {
186 "col1": ["", ""],
187 "col2": ["", ""],
188 "col3": ["value3", "value3"],
189 "col4": ["value4", ""],
190 "col5": ["", "value5"],
191 "col6": ["", "value6"],
192 }
193 assert td.shape == (6, 2)
194 assert list(td) == [
195 ["", "", "value3", "value4", "", ""],
196 ["", "", "value3", "", "value5", "value6"],
197 ]
198
199
200@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 5

row_from_dictMethod · 0.95
keysMethod · 0.95
itemsMethod · 0.95
TabularDataClass · 0.90
dictClass · 0.85

Tested by

no test coverage detected