()
| 97 | |
| 98 | |
| 99 | def test_dict_like_interfaces(): |
| 100 | td = TabularData(["col-1", "col-2"]) |
| 101 | |
| 102 | td.extend([["foo", "bar"], ["foobar", "foobar"]]) |
| 103 | assert td.keys() == ["col-1", "col-2"] |
| 104 | assert dict(td.items()) == { |
| 105 | "col-1": ["foo", "foobar"], |
| 106 | "col-2": ["bar", "foobar"], |
| 107 | } |
| 108 | assert td.as_dict() == [ |
| 109 | {"col-1": "foo", "col-2": "bar"}, |
| 110 | {"col-1": "foobar", "col-2": "foobar"}, |
| 111 | ] |
| 112 | assert td.as_dict(["col-1"]) == [{"col-1": "foo"}, {"col-1": "foobar"}] |
| 113 | |
| 114 | |
| 115 | def test_fill_value(): |