Skip to content

Improve test coverage for edge cases#47

Merged
igormilovanovic merged 1 commit intomasterfrom
test/edge-cases-35
Feb 20, 2026
Merged

Improve test coverage for edge cases#47
igormilovanovic merged 1 commit intomasterfrom
test/edge-cases-35

Conversation

@igormilovanovic
Copy link
Owner

Summary

  • Added 25 new tests in test/test_edge_cases.py covering parsing, file handling, operations, and Host.from_line edge cases
  • Covers empty files, IPv6, malformed lines, inline comments, backup, reload, slicing, repr, and more
  • Total test count: 89 (up from 64)

Closes #35

Test plan

  • All 89 tests pass locally

🤖 Generated with Claude Code

Add 25 new tests covering:
- Empty files, comment-only files, blank lines
- Mixed tabs/spaces, leading/trailing whitespace
- IPv6 entries (::1, fe80::1, 2001:db8::1)
- Malformed lines (invalid IP, IP-only, garbage)
- Inline comment variations
- File handling (nonexistent file, backup, no-header save, reload)
- Operations (remove nonexistent, find multiple by IP, allow_duplicates)
- Slice access, repr/str, __contains__ with wrong type
- Host.from_line edge cases

Closes #35

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

def test_nonexistent_file_creates_empty_list(self):
"""Test that a nonexistent file path results in empty hosts list."""
temp_path = Path(tempfile.mktemp(suffix='.hosts'))

Check failure

Code scanning / CodeQL

Insecure temporary file High test

Call to deprecated function tempfile.mktemp may be insecure.
@igormilovanovic igormilovanovic merged commit f99157d into master Feb 20, 2026
13 of 14 checks passed
@igormilovanovic igormilovanovic deleted the test/edge-cases-35 branch February 20, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test coverage for edge cases

1 participant