MCPcopy
hub / github.com/pandas-dev/pandas / test_display_format_index

Function test_display_format_index

pandas/tests/io/formats/style/test_format.py:60–77  ·  view source on GitHub ↗
(styler, index, columns)

Source from the content-addressed store, hash-verified

58@pytest.mark.parametrize("index", [True, False])
59@pytest.mark.parametrize("columns", [True, False])
60def test_display_format_index(styler, index, columns):
61 exp_index = ["x", "y"]
62 if index:
63 styler.format_index(lambda v: v.upper(), axis=0) # test callable
64 exp_index = ["X", "Y"]
65
66 exp_columns = ["A", "B"]
67 if columns:
68 styler.format_index("*{}*", axis=1) # test string
69 exp_columns = ["*A*", "*B*"]
70
71 ctx = styler._translate(True, True)
72
73 for r, row in enumerate(ctx["body"]):
74 assert row[0]["display_value"] == exp_index[r]
75
76 for c, col in enumerate(ctx["head"][1:]):
77 assert col["display_value"] == exp_columns[c]
78
79
80def test_format_dict(styler):

Callers

nothing calls this directly

Calls 3

format_indexMethod · 0.80
upperMethod · 0.80
_translateMethod · 0.45

Tested by

no test coverage detected