Skip to content

Add test for scan_port handling socket exceptions #3

@m-marinucci

Description

@m-marinucci

As suggested in PR #1 by @sourcery-ai[bot]:

No test exists for scan_port returning False on socket exceptions.

Task: Add a test that simulates a socket exception (e.g., connect_ex or recv raising) and verifies that scan_port returns False.

Example test:

def test_scan_port_socket_exception(self):
    """Test that scan_port returns False on socket exceptions."""
    with patch('socket.socket') as mock_socket:
        mock_socket.side_effect = Exception("Socket error")
        result = scan_port("127.0.0.1", 80)
        assert result is False

File: tests/test_network_scanner.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions