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

Function test_table_empty

tests/unit/test_tabular_data.py:8–42  ·  view source on GitHub ↗
(capsys)

Source from the content-addressed store, hash-verified

6
7
8def test_table_empty(capsys):
9 td = TabularData(["Col1", "Col2", "Col3"])
10 assert dict(td.items()) == {"Col1": [], "Col2": [], "Col3": []}
11 assert td.columns == [[], [], []]
12 assert td.keys() == ["Col1", "Col2", "Col3"]
13 assert list(td) == []
14 assert td.Col1 == []
15 assert td.Col2 == []
16 assert td.Col3 == []
17
18 assert td[1:] == []
19 with pytest.raises(IndexError):
20 _ = td[1]
21
22 assert len(td) == 0
23 assert td.shape == (3, 0)
24 assert td.to_csv() == """Col1,Col2,Col3\r\n"""
25
26 td.render()
27 assert capsys.readouterr() == ("", "")
28
29 td.render(rich_table=True)
30 assert capsys.readouterr() == ("", "")
31
32 td.render(markdown=True)
33 assert capsys.readouterr() == (
34 "| Col1 | Col2 | Col3 |\n|--------|--------|--------|\n\n",
35 "",
36 )
37
38 td.rename("Col1", "Col11")
39 assert td.keys() == ["Col11", "Col2", "Col3"]
40
41 td.project("Col3", "Col11")
42 assert td.keys() == ["Col3", "Col11"]
43
44
45def test_list_operations():

Callers

nothing calls this directly

Calls 8

itemsMethod · 0.95
keysMethod · 0.95
to_csvMethod · 0.95
renderMethod · 0.95
renameMethod · 0.95
projectMethod · 0.95
TabularDataClass · 0.90
dictClass · 0.85

Tested by

no test coverage detected