Comments (3)
@mattoberle Thanks for the details test case! I think I've discovered the logical error - and am working on figuring out the right approach to resolve.
TL,DR: there's a logical conflict between the config options, leading to failed outcomes. This is likely to change the
flag combinations, so I'm treading carefully.
from pytest-socket.
@ryanjdillon can you provide more details as to the scenario?
Probably a code snippet, test scenario, configs and Paramus passes to pytest so I can try to reproduce?
from pytest-socket.
I think this is the same issue from #70 / #71.
The combination of --allow-unix-socket
and --allow-hosts
does not work as expected.
Take this example test:
import socket
import pytest
def test_unix_connect():
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
with pytest.raises(FileNotFoundError):
sock.connect('/tmp/socket.sock')
def test_inet_connect():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
with pytest.raises(ConnectionRefusedError):
sock.connect(('127.0.0.1', 8080))
🟢 Running pytest without the plugin will pass (expected):
$ pytest test.py
🟢 Running pytest with --disable-socket
will result in two failures (expected):
$ pytest --disable-socket test.py
FAILED test.py::test_unix_connect - pytest_socket.SocketBlockedError: A test tried to use socket.socket.
FAILED test.py::test_inet_connect - pytest_socket.SocketBlockedError: A test tried to use socket.socket.
🟢 Running pytest with --disable-socket --allow-unix-socket
will result in one failure for the TCP socket use (expected):
$ pytest --disable-socket --allow-unix-socket test.py
FAILED example_test.py::test_inet_connect - pytest_socket.SocketBlockedError: A test tried to use socket.socket.
🔴 Running pytest with --allow-unix-socket --allow-hosts=127.0.0.1
will result in one failure for the Unix socket use (unexpected):
$ pytest --allow-unix-socket --allow-hosts=127.0.0.1
FAILED example_test.py::test_unix_connect - pytest_socket.SocketConnectBlockedError: A test tried to use socket.socket.connect() with host "None" (allowed: "127.0.0.1").
from pytest-socket.
Related Issues (20)
- Incompatibility with pytest-flakes? HOT 2
- `remove_host_restrictions` functionality no longer in the public interface HOT 3
- 0.5.0: pytest is failing in `tests/test_async.py::test_starlette` unit HOT 4
- pytest-socket blocks retrieving other dependencies HOT 1
- Issue with sockets when trying to run Home Assistant tests HOT 2
- 0.5.1: pytest is failing in `tests/test_async.py::test_httpx_fails` unit HOT 11
- Question about asynctest and Python 3.8+ compatibility HOT 3
- Action Required: Fix Renovate Configuration
- dd-trace calls in separate thread do not fail test HOT 7
- Allow host masks HOT 2
- Allow private networks only HOT 5
- Issue with latest pytest-socket version while using testcontainers HOT 6
- Try replacement for httpbin HOT 1
- Do not install files directly to site-packages HOT 2
- --allow-hosts list is normalized but connection host is not HOT 5
- Update Python version support HOT 1
- vscode-python version 2023.20.0 breaks disable_socket expected behavior HOT 2
- Option to only block `connect` calls? HOT 2
- 0.7.0: test suite fails HOT 6
- pytest-socket raises IndexError when used with httpx
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-socket.