diff --git a/CHANGELOG.md b/CHANGELOG.md index 7180fad..fe7e80c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +### What's New? + +- Show detailed error for missing bitmaps in `ctgen` cursors config parsing + ## [v2.2.3] - 25 May 2024 ### What's New? diff --git a/src/clickgen/configparser.py b/src/clickgen/configparser.py index 589ef04..d59c755 100644 --- a/src/clickgen/configparser.py +++ b/src/clickgen/configparser.py @@ -107,6 +107,11 @@ def size_typing(s: Union[int, List[int]]) -> List[int]: blobs = [f.read_bytes() for f in sorted(config.bitmaps_dir.glob(v["png"]))] + if not blobs: + raise FileNotFoundError( + f"Bitmaps not found '{v["png"]}' in '{config.bitmaps_dir}'" + ) + x11_cursor = None x11_cursor_name = None if "x11_name" in v: diff --git a/tests/test_configparser.py b/tests/test_configparser.py index 7eea66d..9209381 100644 --- a/tests/test_configparser.py +++ b/tests/test_configparser.py @@ -1,9 +1,12 @@ from pathlib import Path +import pytest + from clickgen.configparser import ( ClickgenConfig, parse_config_file, parse_config_section, + parse_cursors_section, parse_json_file, parse_theme_section, parse_toml_file, @@ -75,10 +78,10 @@ def test_x11_sizes_deprecation_message(capsys): def test_parse_config_section(): c = parse_config_section(Path(), dd2) assert isinstance(c.bitmaps_dir, Path) - assert c.bitmaps_dir.name is "test" + assert c.bitmaps_dir.name == "test" assert c.bitmaps_dir.is_absolute() assert isinstance(c.out_dir, Path) - assert c.out_dir.name is "test" + assert c.out_dir.name == "test" assert c.out_dir.is_absolute() assert c.platforms == "test" @@ -178,3 +181,17 @@ def test_parse_config_files(samples_dir: Path): fp = samples_dir / f"sample.{ext}" c: ClickgenConfig = parse_config_file(fp) assert_clickgen_config(c) + + +def test_parse_cursor_section_handles_png_not_found_exception(): + exp_dd1 = dd1 + exp_dd1["cursors"] = { + "fallback_settings": {}, + "bitmap1": {"png": "test.png", "x11_name": "test", "win_name": "test"}, + } + + c = parse_config_section(Path(), dd2) + + with pytest.raises(FileNotFoundError) as e: + parse_cursors_section(exp_dd1, c) + print(e)