Skip to content

Commit d8d6ecc

Browse files
committed
Increase coverage
1 parent 5eb76d1 commit d8d6ecc

File tree

5 files changed

+45
-34
lines changed

5 files changed

+45
-34
lines changed

.github/codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ coverage:
1919
patch:
2020
default:
2121
target: 80%
22+
23+
ignore:
24+
- "apps/"

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ jobs:
7171
numpy-version: '<2.0'
7272
- python-version: "3.13"
7373
pandas-version: pre
74-
polars: true
7574
- python-version: "3.13"
7675
uninstall_non_essential_dependencies: true
7776
- python-version: "3.10"
@@ -110,16 +109,12 @@ jobs:
110109
if: matrix.typeguard-version != 'latest'
111110
run: pip install 'typeguard${{ matrix.typeguard-version }}'
112111

113-
- name: Install polars
114-
if: matrix.polars
115-
run: pip install -e .[polars]
116-
117112
- name: Install shiny
118113
run: pip install "shiny>=1.0" shinywidgets
119114

120115
- name: Uninstall non-essential dependencies
121116
if: matrix.uninstall_non_essential_dependencies
122-
run: pip uninstall jinja2 dash anywidget streamlit shiny shinywidgets -y
117+
run: pip uninstall polars jinja2 dash anywidget streamlit shiny shinywidgets -y
123118

124119
- name: Install a Jupyter Kernel
125120
run: python -m ipykernel install --name itables --user

packages/dt_for_itables/add_host_to_root.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,21 @@ def process_rule(match):
6161
return re.sub(pattern, process_rule, css_content)
6262

6363

64-
if __name__ == "__main__":
65-
66-
def main():
67-
parser = argparse.ArgumentParser(
68-
description="Add :host to each :root selector in a CSS file."
69-
)
70-
parser.add_argument("css_file", help="Path to the CSS file to modify")
71-
args = parser.parse_args()
64+
def main(argv):
65+
parser = argparse.ArgumentParser(
66+
description="Add :host to each :root selector in a CSS file."
67+
)
68+
parser.add_argument("css_file", help="Path to the CSS file to modify")
69+
args = parser.parse_args(argv[1:])
7270

73-
try:
74-
with open(args.css_file, "r") as file:
75-
css_content = file.read()
71+
with open(args.css_file, "r") as file:
72+
css_content = file.read()
7673

77-
modified_content = add_host_to_root(css_content)
74+
modified_content = add_host_to_root(css_content)
7875

79-
with open(args.css_file, "w") as file:
80-
file.write(modified_content)
76+
with open(args.css_file, "w") as file:
77+
file.write(modified_content)
8178

82-
print(f"Successfully updated {args.css_file}")
83-
return 0
84-
except FileNotFoundError:
85-
print(f"Error: File {args.css_file} not found.")
86-
return 1
87-
except Exception as e:
88-
print(f"Error processing file: {e}")
89-
return 1
9079

91-
sys.exit(main())
80+
if __name__ == "__main__":
81+
sys.exit(main(sys.argv))

packages/dt_for_itables/test_add_host_to_root.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from add_host_to_root import add_host_to_root
2+
from add_host_to_root import add_host_to_root, main
33

44

55
def test_add_host_to_root_example():
@@ -66,3 +66,15 @@ def test_add_host_to_root_complex_selectors():
6666
:root[data-theme="light"] .element, :host[data-theme="light"] .element { background-color: white; }
6767
"""
6868
assert add_host_to_root(original_css) == expected_css
69+
70+
71+
def test_main_function(tmp_path):
72+
"""Test the main function modifies the file as expected."""
73+
css_content = ":root { color: red; }"
74+
expected_content = ":root, :host { color: red; }"
75+
css_file = tmp_path / "test.css"
76+
css_file.write_text(css_content)
77+
78+
main(["add_host_to_root.py", str(css_file)])
79+
result = css_file.read_text()
80+
assert result == expected_content

tests/test_documentation_notebooks_run.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import subprocess
2+
import sys
13
from pathlib import Path
24

35
import jupytext
@@ -34,15 +36,24 @@ def test_run_documentation_notebooks(notebook):
3436
pytest.skip("Polars is not available")
3537
if "pandas_style" in notebook.stem and pd_style is None:
3638
pytest.skip("Pandas Style is not available")
37-
if "shiny" in notebook.stem:
38-
pytest.skip("shinywidgets makes the widget.md notebook fail")
3939
if "marimo" in notebook.stem or "widget" in notebook.stem:
4040
pytest.importorskip("anywidget")
4141

42-
org_options = dir(opt)
43-
4442
nb = jupytext.read(notebook)
4543
py_notebook = jupytext.writes(nb, "py:percent")
44+
if "shiny" in notebook.stem:
45+
# we can't use exec as shinywidgets makes the widget.md notebook fail
46+
result = subprocess.run(
47+
[sys.executable, "-c", py_notebook], capture_output=True, text=True
48+
)
49+
if result.returncode != 0:
50+
if "ModuleNotFoundError: No module named 'shinywidgets'" in result.stderr:
51+
pytest.skip("shinywidgets is not available")
52+
assert result.returncode == 0, result.stderr
53+
return
54+
55+
org_options = dir(opt)
56+
4657
exec(py_notebook, {})
4758

4859
new_options = set(dir(opt)).difference(org_options)

0 commit comments

Comments
 (0)