The test suite fails to start, and the following error is displayed:
vscode_pytest.VSCodePytestError: Error attempting to connect to extension communication socket[vscode-pytest]: A test tried to use socket.socket.connect() with host "localhost" (allowed: "127.0.0.1").
In plugin.py changing on line 144 change
pytest_socket.socket_allow_hosts(["127.0.0.1"]) to
pytest_socket.socket_allow_hosts(["127.0.0.1", "localhost"])
resolves the issue.
It would seem that this setting can't be overridden by these other settings listed above, only by allowing this plugin to accept hosts from localhost in addition to 127.0.0.1
Environment:
Operating System: win10 Development Environment: Visual Studio Code Python Version: 3.12.1 Pytest Version: 7.4.3 pytest-socket: 0.6.0 pytest-homeassistant-custom-component: 0.13.88
Steps to Reproduce:
Clone https://github.com/watkins-matt/home-assistant-google-keep-sync setup new venv and try to run pytest within vscode
Expected Behavior:
The test suite runs without any issues.
Actual Behavior:
The test suite fails to start, and the following error is displayed:
vscode_pytest.VSCodePytestError: Error attempting to connect to extension communication socket[vscode-pytest]: A test tried to use socket.socket.connect() with host "localhost" (allowed: "127.0.0.1").
Additional Information:
Tried the following without any luck:
"python.experiments.enabled": false
Suggested Fix
The aparent source of the issue was found in a separate issue https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/issues/171#issuecomment-1879449450
In plugin.py changing on line 144 change
pytest_socket.socket_allow_hosts(["127.0.0.1"])
topytest_socket.socket_allow_hosts(["127.0.0.1", "localhost"])
resolves the issue.It would seem that this setting can't be overridden by these other settings listed above, only by allowing this plugin to accept hosts from localhost in addition to 127.0.0.1