Skip to content

Commit 252be8c

Browse files
committed
type fixes
1 parent d3ab0dc commit 252be8c

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

tests/test_pocket_build.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33

44
import json
55
from pathlib import Path
6+
from typing import Any, Dict
7+
8+
import pytest
9+
from _pytest.monkeypatch import MonkeyPatch
610

711
from pocket_build import pocket_build
12+
from pocket_build.pocket_build import BuildConfig
813

914

1015
# ------------------------------------------------------------
@@ -27,16 +32,16 @@ def test_load_jsonc_strips_comments_and_trailing_commas(tmp_path: Path):
2732

2833

2934
def test_parse_builds_accepts_list_and_single_object():
30-
data_list = {"builds": [{"include": ["src"], "out": "dist"}]}
31-
data_single = {"include": ["src"], "out": "dist"}
35+
data_list: Dict[str, Any] = {"builds": [{"include": ["src"], "out": "dist"}]}
36+
data_single: Dict[str, Any] = {"include": ["src"], "out": "dist"}
3237

3338
builds_from_list = pocket_build.parse_builds(data_list)
3439
builds_from_single = pocket_build.parse_builds(data_single)
3540

3641
assert isinstance(builds_from_list, list)
3742
assert isinstance(builds_from_single, list)
38-
assert builds_from_list[0]["out"] == "dist"
39-
assert builds_from_single[0]["out"] == "dist"
43+
assert builds_from_list[0].get("out") == "dist"
44+
assert builds_from_single[0].get("out") == "dist"
4045

4146

4247
# ------------------------------------------------------------
@@ -54,7 +59,9 @@ def test_is_excluded_matches_patterns(tmp_path: Path):
5459
# ------------------------------------------------------------
5560
# 📄 Copy helpers
5661
# ------------------------------------------------------------
57-
def test_copy_file_creates_and_copies(tmp_path: Path, capsys):
62+
def test_copy_file_creates_and_copies(
63+
tmp_path: Path, capsys: pytest.CaptureFixture[str]
64+
):
5865
src = tmp_path / "a.txt"
5966
src.write_text("hi")
6067
dest = tmp_path / "out" / "a.txt"
@@ -66,7 +73,9 @@ def test_copy_file_creates_and_copies(tmp_path: Path, capsys):
6673
assert "📄" in captured
6774

6875

69-
def test_copy_directory_respects_excludes(tmp_path: Path, capsys):
76+
def test_copy_directory_respects_excludes(
77+
tmp_path: Path, capsys: pytest.CaptureFixture[str]
78+
):
7079
src_dir = tmp_path / "src"
7180
src_dir.mkdir()
7281
(src_dir / "keep.txt").write_text("ok")
@@ -95,13 +104,15 @@ def test_copy_item_handles_file_and_dir(tmp_path: Path):
95104
# ------------------------------------------------------------
96105
# 🏗️ Build execution
97106
# ------------------------------------------------------------
98-
def test_run_build_creates_output_dir_and_copies(tmp_path: Path, capsys):
107+
def test_run_build_creates_output_dir_and_copies(
108+
tmp_path: Path, capsys: pytest.CaptureFixture[str]
109+
):
99110
# Arrange: create a small directory structure
100111
src_dir = tmp_path / "src"
101112
src_dir.mkdir()
102113
(src_dir / "foo.txt").write_text("foo")
103114

104-
build_cfg = {
115+
build_cfg: BuildConfig = {
105116
"include": ["src"],
106117
"exclude": [],
107118
"out": "dist",
@@ -117,8 +128,10 @@ def test_run_build_creates_output_dir_and_copies(tmp_path: Path, capsys):
117128
assert "✅ Build completed" in captured
118129

119130

120-
def test_run_build_handles_missing_match(tmp_path: Path, capsys):
121-
cfg = {"include": ["nonexistent"], "out": "dist"}
131+
def test_run_build_handles_missing_match(
132+
tmp_path: Path, capsys: pytest.CaptureFixture[str]
133+
):
134+
cfg: BuildConfig = {"include": ["nonexistent"], "out": "dist"}
122135
pocket_build.run_build(cfg, tmp_path, None)
123136
captured = capsys.readouterr().out
124137
assert "⚠️" in captured
@@ -127,15 +140,19 @@ def test_run_build_handles_missing_match(tmp_path: Path, capsys):
127140
# ------------------------------------------------------------
128141
# 🎛️ Main entry
129142
# ------------------------------------------------------------
130-
def test_main_no_config(tmp_path: Path, monkeypatch, capsys):
143+
def test_main_no_config(
144+
tmp_path: Path, monkeypatch: MonkeyPatch, capsys: pytest.CaptureFixture[str]
145+
):
131146
monkeypatch.chdir(tmp_path)
132147
code = pocket_build.main([])
133148
assert code == 1
134149
out = capsys.readouterr().out
135150
assert "No build config" in out
136151

137152

138-
def test_main_with_config(tmp_path: Path, monkeypatch, capsys):
153+
def test_main_with_config(
154+
tmp_path: Path, monkeypatch: MonkeyPatch, capsys: pytest.CaptureFixture[str]
155+
):
139156
config = tmp_path / ".pocket-build.json"
140157
config.write_text(json.dumps({"builds": [{"include": [], "out": "dist"}]}))
141158
monkeypatch.chdir(tmp_path)

0 commit comments

Comments
 (0)