Comments (4)
Thanks for the detailed report!
This seems like a logical bug, and I'll have to dig into it a bit more - since from the outset, I think it's confusing to the user that passing --allow-hosts=...
without the --disable-socket
isn't exactly the intended behavior either.
I can confirm that setting the .ini
to:
[pytest]
addopts = --disable-socket --allow-hosts=127.0.0.1
and running the test, all 3 requests are blocked, since none of the target IPs match 127.0.0.1
.
Can you help me understand what outcome you expected?
from pytest-socket.
Hello Mike.
I tried your configuration but it does the opposite of what I expect.
I expect that, by default it does not allow socket. So when I pass socket_enabled
in my test, then they should be allowed.
In my example, the first one is not allowed, then the two others are. The three of them should be allowed since I used socket_enabled
.
By adding --disable-socket
things get worse, as none of them are allowed, although I have the socket_enabled
as argument in my test. So I think you just found another issue.
from pytest-socket.
@fj-dt I wrote a test here: 3b61b28
If I read your desire correctly, you're expecting the inline socket_enabled
to override the config setting, and allow those three remote calls, instead of failing all three?
from pytest-socket.
@miketheman Correct. 👍
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
- Replace pytest-flake8 with a pre-commit hook
- 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.