test: add -> None return type annotations to all test methods
Some checks failed
CI / test (push) Has been cancelled
Shellhist CI / test (push) Has been cancelled
Shellhist CI / build (push) Has been cancelled

This commit is contained in:
2026-01-31 14:21:28 +00:00
parent 7b3ceb1439
commit f61a58cfb5

View File

@@ -8,7 +8,7 @@ from shellhist.core.search import fuzzy_search, rank_by_frequency
class TestFuzzySearch: class TestFuzzySearch:
"""Test fuzzy search functionality.""" """Test fuzzy search functionality."""
def setup_method(self): def setup_method(self) -> None:
"""Set up test fixtures.""" """Set up test fixtures."""
self.store = HistoryStore() self.store = HistoryStore()
@@ -29,32 +29,32 @@ class TestFuzzySearch:
entry = HistoryEntry(command=cmd, line_number=i) entry = HistoryEntry(command=cmd, line_number=i)
self.store.add_entry(entry) self.store.add_entry(entry)
def test_basic_search(self): def test_basic_search(self) -> None:
"""Test basic fuzzy search.""" """Test basic fuzzy search."""
results = fuzzy_search(self.store, "git status", threshold=50) results = fuzzy_search(self.store, "git status", threshold=50)
assert len(results) > 0 assert len(results) > 0
assert any(r[0].command == "git status" for r in results) assert any(r[0].command == "git status" for r in results)
def test_search_with_threshold(self): def test_search_with_threshold(self) -> None:
"""Test search with custom threshold.""" """Test search with custom threshold."""
results = fuzzy_search(self.store, "git commit message", threshold=80) results = fuzzy_search(self.store, "git commit message", threshold=80)
assert all(r[1] >= 80 for r in results) assert all(r[1] >= 80 for r in results)
def test_search_no_match(self): def test_search_no_match(self) -> None:
"""Test search with no matches.""" """Test search with no matches."""
results = fuzzy_search(self.store, "xyz123nonexistent", threshold=70) results = fuzzy_search(self.store, "xyz123nonexistent", threshold=70)
assert len(results) == 0 assert len(results) == 0
def test_search_limit(self): def test_search_limit(self) -> None:
"""Test search result limit.""" """Test search result limit."""
results = fuzzy_search(self.store, "git", threshold=50, limit=3) results = fuzzy_search(self.store, "git", threshold=50, limit=3)
assert len(results) <= 3 assert len(results) <= 3
def test_search_reverse_sort(self): def test_search_reverse_sort(self) -> None:
"""Test search with reverse sorting.""" """Test search with reverse sorting."""
results_normal = fuzzy_search(self.store, "git", threshold=50, reverse=False) results_normal = fuzzy_search(self.store, "git", threshold=50, reverse=False)
results_reverse = fuzzy_search(self.store, "git", threshold=50, reverse=True) results_reverse = fuzzy_search(self.store, "git", threshold=50, reverse=True)
@@ -62,7 +62,7 @@ class TestFuzzySearch:
if len(results_normal) > 1: if len(results_normal) > 1:
assert results_normal != results_reverse assert results_normal != results_reverse
def test_search_recent_boost(self): def test_search_recent_boost(self) -> None:
"""Test that recent commands get boosted.""" """Test that recent commands get boosted."""
from datetime import datetime, timedelta from datetime import datetime, timedelta
@@ -92,7 +92,7 @@ class TestFuzzySearch:
class TestRankByFrequency: class TestRankByFrequency:
"""Test frequency ranking functionality.""" """Test frequency ranking functionality."""
def setup_method(self): def setup_method(self) -> None:
"""Set up test fixtures.""" """Set up test fixtures."""
self.store = HistoryStore() self.store = HistoryStore()
@@ -104,7 +104,7 @@ class TestRankByFrequency:
self.store.add_entry(HistoryEntry(command="ls")) self.store.add_entry(HistoryEntry(command="ls"))
def test_rank_by_frequency(self): def test_rank_by_frequency(self) -> None:
"""Test ranking results by frequency.""" """Test ranking results by frequency."""
entry = HistoryEntry(command="git status") entry = HistoryEntry(command="git status")
results = [(entry, 100)] results = [(entry, 100)]
@@ -114,7 +114,7 @@ class TestRankByFrequency:
assert len(ranked) == 1 assert len(ranked) == 1
assert ranked[0][2] == 5 assert ranked[0][2] == 5
def test_rank_multiple(self): def test_rank_multiple(self) -> None:
"""Test ranking multiple results.""" """Test ranking multiple results."""
entry1 = HistoryEntry(command="git status") entry1 = HistoryEntry(command="git status")
entry2 = HistoryEntry(command="git log") entry2 = HistoryEntry(command="git log")