GithubHelp home page GithubHelp logo

Comments (3)

miketheman avatar miketheman commented on June 1, 2024 1

@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.

miketheman avatar miketheman commented on June 1, 2024

@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.

mattoberle avatar mattoberle commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.