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:27 +00:00
parent 4fb0b6ff88
commit 7b3ceb1439

View File

@@ -12,7 +12,7 @@ from shellhist.core import HistoryEntry, HistoryStore, HistoryLoader
class TestHistoryEntry:
"""Test HistoryEntry dataclass."""
def test_create_entry(self):
def test_create_entry(self) -> None:
"""Test creating a basic history entry."""
entry = HistoryEntry(command="git status")
assert entry.command == "git status"
@@ -20,13 +20,13 @@ class TestHistoryEntry:
assert entry.line_number == 0
assert entry.shell_type == "unknown"
def test_entry_with_timestamp(self):
def test_entry_with_timestamp(self) -> None:
"""Test creating an entry with timestamp."""
ts = datetime.now()
entry = HistoryEntry(command="ls -la", timestamp=ts)
assert entry.timestamp == ts
def test_entry_equality(self):
def test_entry_equality(self) -> None:
"""Test entry equality based on command."""
entry1 = HistoryEntry(command="git status")
entry2 = HistoryEntry(command="git status")
@@ -35,7 +35,7 @@ class TestHistoryEntry:
assert entry1 == entry2
assert entry1 != entry3
def test_entry_hash(self):
def test_entry_hash(self) -> None:
"""Test entry hash for use in sets/dicts."""
entry1 = HistoryEntry(command="git status")
entry2 = HistoryEntry(command="git status")
@@ -47,13 +47,13 @@ class TestHistoryEntry:
class TestHistoryStore:
"""Test HistoryStore class."""
def test_empty_store(self):
def test_empty_store(self) -> None:
"""Test creating an empty store."""
store = HistoryStore()
assert len(store.entries) == 0
assert len(store.command_frequency) == 0
def test_add_entry(self):
def test_add_entry(self) -> None:
"""Test adding entries to the store."""
store = HistoryStore()
entry = HistoryEntry(command="git status")
@@ -63,7 +63,7 @@ class TestHistoryStore:
assert len(store.entries) == 1
assert store.get_frequency("git status") == 1
def test_frequency_tracking(self):
def test_frequency_tracking(self) -> None:
"""Test command frequency tracking."""
store = HistoryStore()
@@ -76,7 +76,7 @@ class TestHistoryStore:
assert store.get_frequency("git log") == 1
assert store.get_frequency("unknown") == 0
def test_most_frequent(self):
def test_most_frequent(self) -> None:
"""Test getting most frequent commands."""
store = HistoryStore()
@@ -91,7 +91,7 @@ class TestHistoryStore:
assert most_frequent[0] == ("git status", 3)
assert most_frequent[1] == ("git log", 1)
def test_get_unique_commands(self):
def test_get_unique_commands(self) -> None:
"""Test getting unique commands."""
store = HistoryStore()
@@ -109,7 +109,7 @@ class TestHistoryStore:
class TestHistoryLoader:
"""Test HistoryLoader class."""
def test_load_bash_history(self):
def test_load_bash_history(self) -> None:
"""Test parsing bash history format."""
with tempfile.NamedTemporaryFile(mode='w', suffix='_bash_history', delete=False) as f:
f.write("git status\n")
@@ -132,7 +132,7 @@ class TestHistoryLoader:
finally:
os.unlink(temp_path)
def test_load_bash_history_with_timestamps(self):
def test_load_bash_history_with_timestamps(self) -> None:
"""Test parsing bash history with timestamps."""
with tempfile.NamedTemporaryFile(mode='w', suffix='_bash_history', delete=False) as f:
f.write("#1700000000\n")
@@ -150,7 +150,7 @@ class TestHistoryLoader:
finally:
os.unlink(temp_path)
def test_load_zsh_history(self):
def test_load_zsh_history(self) -> None:
"""Test parsing zsh history format."""
import os
with tempfile.NamedTemporaryFile(mode='w', suffix='_zsh_history', delete=False) as f:
@@ -170,14 +170,14 @@ class TestHistoryLoader:
finally:
os.unlink(temp_path)
def test_file_not_found(self):
def test_file_not_found(self) -> None:
"""Test error handling for missing file."""
loader = HistoryLoader(history_path="/nonexistent/path")
with pytest.raises(FileNotFoundError):
loader.load()
def test_from_file_convenience_method(self):
def test_from_file_convenience_method(self) -> None:
"""Test the from_file class method."""
with tempfile.NamedTemporaryFile(mode='w', suffix='_history', delete=False) as f:
f.write("echo test\n")