Skip to content

Refactor duplicated get_default_ip() function into common utility module #453

@coderabbitai

Description

@coderabbitai

Problem

The get_default_ip() function is currently duplicated in multiple test files:

  • tests/test_hear_cleanup.py (lines 176-200)
  • tests/test_hear_server.py

This violates DRY principles and creates maintenance overhead.

Proposed Solution

Refactor the get_default_ip() function into a common location, with suggested targets:

  1. tests.context module - Most appropriate for test utility functions
  2. multicast.skt module - Alternative location if it fits better with socket utilities

Implementation Notes

  • Remove duplicate implementations from individual test files
  • Import the centralized function where needed
  • Ensure consistent behavior across all usage points
  • Update any related documentation

Context

This refactoring was identified during code review in PR #448. The function implements RFC 5737 compliant IP detection using TEST-NET-3 (203.0.113.1) and is well-designed but should not be duplicated.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChoreMiscellaneous chores to maintain the projectPython LangChanges to Python source codeTestingSomething can be verifiedgood first issueGood for newcomers

    Type

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions