test: cover ipaddr module #29
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/confconsole!29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tests/ipaddr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #24
Added tests/test_ipaddr.py and put ipaddr in the package list in tests.yml. Didn't touch ipaddr.py.
Tests cover:
in(network and broadcast count as outside), fmt_cidr, str and reprRan the coverage commands from CI: 951 passed, 7 skipped, ipaddr.py at 100%.
Side note: cidr is calculated with math.log, so some prefixes come out wrong (/1 gives 0, /3 gives 2). Left it alone since this issue is tests only, and the tests just use /24. Can open an issue for it if you want.
Hi @Nandika-Gupta, really nice work again!
I ran it: all 27 new tests pass, the full suite passes, and ipaddr.py is at 100% line and branch coverage, untouched. Great choice using the RFC 5737 documentation ranges.
Two things you found deserve a mention, because they're the real value of tests like these:
One more thing your tests surface, for a follow-up rather than this PR: IP() accepts any integer without checking the range, so IP(2**32) or IP(-1) are created fine and only fail later, in str(), with a confusing struct.error. Would you like to open an issue describing it? A clear error at construction (Error("ip out of range")) would be the likely fix.
I'll merge once CI is green. Thanks!
Thanks a lot for the detailed review and for merging! I've raised a follow-up PR for the IP() range check based on your suggestion: #30