Skip to content

Commit 754cb33

Browse files
committed
Distribute edge case tests into appropriate test files
Move tests from standalone test_coverage_improvements.py into existing test files where they belong: - test_flu.py: 52 edge case tests added inline to existing test functions - Empty iterator handling (reduce, min, max, sum, count) - Attribute/item access errors (map_item, map_attr) - Parameter edge cases (head/tail/take with 0, collect with 0) - __getitem__ edge cases (negative index, slices with step) - Side effect exception handling - Integration tests for complex pipelines - test_cli.py: 4 error handling tests - Non-existent module import - Non-existent attribute import - Empty import list - Exception propagation from commands - test_cli_utils.py: 4 utility edge case tests - Return type verification - Empty directory handling Removed standalone coverage files in favor of inline tests.
1 parent d551bbb commit 754cb33

File tree

5 files changed

+215
-575
lines changed

5 files changed

+215
-575
lines changed

TEST_COVERAGE_ANALYSIS.md

Lines changed: 0 additions & 143 deletions
This file was deleted.

src/tests/test_cli.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,30 @@ def test_glob_imports(capsys):
109109
result = capsys.readouterr()
110110
stdout = result.out
111111
assert stdout
112+
113+
114+
# Error handling tests
115+
116+
117+
def test_import_nonexistent_module_raises():
118+
"""Importing non-existent module should raise ModuleNotFoundError."""
119+
with pytest.raises(ModuleNotFoundError):
120+
build_import_dict(["nonexistent_module_xyz123"])
121+
122+
123+
def test_import_nonexistent_attribute_raises():
124+
"""Importing non-existent attribute should raise AttributeError."""
125+
with pytest.raises(AttributeError):
126+
build_import_dict(["json:nonexistent_function"])
127+
128+
129+
def test_build_import_dict_empty_list():
130+
"""build_import_dict with empty list should return empty dict."""
131+
result = build_import_dict([])
132+
assert result == {}
133+
134+
135+
def test_cli_exception_in_command():
136+
"""CLI should propagate exceptions from user commands."""
137+
with pytest.raises(ZeroDivisionError):
138+
main(["flu", "1/0"])

src/tests/test_cli_utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from flupy import flu
12
from flupy.cli.utils import walk_dirs, walk_files
23

34

@@ -8,3 +9,36 @@ def test_walk_files():
89

910
def test_walk_dirs():
1011
assert walk_dirs().head()
12+
13+
14+
# Edge case tests
15+
16+
17+
def test_walk_files_returns_fluent():
18+
"""walk_files() should return a Fluent object."""
19+
result = walk_files()
20+
assert isinstance(result, flu)
21+
22+
23+
def test_walk_dirs_returns_fluent():
24+
"""walk_dirs() should return a Fluent object."""
25+
result = walk_dirs()
26+
assert isinstance(result, flu)
27+
28+
29+
def test_walk_files_empty_directory(tmp_path):
30+
"""walk_files() on empty directory should return empty."""
31+
empty_dir = tmp_path / "empty"
32+
empty_dir.mkdir()
33+
result = walk_files(str(empty_dir)).collect()
34+
assert result == []
35+
36+
37+
def test_walk_dirs_empty_directory(tmp_path):
38+
"""walk_dirs() on directory with no subdirs returns root only."""
39+
empty_dir = tmp_path / "empty"
40+
empty_dir.mkdir()
41+
result = walk_dirs(str(empty_dir)).collect()
42+
# walk_dirs includes the root directory itself
43+
assert len(result) == 1
44+
assert str(empty_dir) in result[0]

0 commit comments

Comments
 (0)