Skip to content

Commit 90d0a1b

Browse files
committed
testing!
1 parent 89c87a4 commit 90d0a1b

File tree

2 files changed

+75
-6
lines changed

2 files changed

+75
-6
lines changed

gt_extras/styling.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ def gt_add_divider(
1818
weight: int = 2,
1919
include_labels: bool = True,
2020
) -> GT:
21-
locations = [
22-
loc.body(
23-
columns=columns,
24-
)
25-
]
21+
locations = [loc.body(columns=columns)]
2622

2723
if include_labels:
2824
locations.append(loc.column_labels(columns=columns))

gt_extras/tests/test_styling.py

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,75 @@
1+
import pandas as pd
2+
from great_tables import GT
3+
4+
from gt_extras.styling import gt_add_divider
5+
6+
17
def test_gt_add_divider_basic():
2-
pass
8+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
9+
gt = GT(df)
10+
11+
html = gt_add_divider(gt, columns="A").as_raw_html()
12+
13+
assert html.count("border-right:") == 3
14+
assert html.count("2px solid grey") == 3
15+
16+
17+
def test_gt_add_divider_multiple_columns():
18+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4], "C": [5, 6]})
19+
gt = GT(df)
20+
21+
html = gt_add_divider(gt, columns=["A", "B"]).as_raw_html()
22+
23+
assert html.count("border-right: 2px solid grey") == 2 * 3
24+
25+
26+
def test_gt_add_divider_custom_sides():
27+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
28+
gt = GT(df)
29+
30+
html = gt_add_divider(gt, columns="A", sides="left").as_raw_html()
31+
32+
assert html.count("border-left:") == 3
33+
assert "border-right:" not in html
34+
35+
36+
def test_gt_add_divider_custom_color_and_style():
37+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
38+
gt = GT(df)
39+
40+
res = gt_add_divider(gt, columns="A", color="blue", divider_style="dashed")
41+
html = res.as_raw_html()
42+
43+
assert "border-right: 2px dashed blue;" in html
44+
assert "grey" not in html
45+
46+
47+
def test_gt_add_divider_custom_weight():
48+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
49+
gt = GT(df)
50+
51+
html = gt_add_divider(gt, columns="A", weight=5).as_raw_html()
52+
53+
assert "border-right: 5px solid grey;" in html
54+
assert "2px solid grey" not in html
55+
56+
57+
def test_gt_add_divider_exclude_labels():
58+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
59+
gt = GT(df)
60+
61+
html = gt_add_divider(gt, columns="A", include_labels=False).as_raw_html()
62+
63+
assert html.count("border-right:") == 2
64+
65+
66+
def test_gt_add_divider_multiple_sides():
67+
df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
68+
gt = GT(df)
69+
70+
html = gt_add_divider(gt, columns="A", sides=["top", "bottom"]).as_raw_html()
71+
72+
assert "border-top:" in html
73+
assert "border-bottom:" in html
74+
assert "border-right:" not in html
75+
assert "border-left:" not in html

0 commit comments

Comments
 (0)