GithubHelp home page GithubHelp logo

Comments (3)

miketheman avatar miketheman commented on June 14, 2024

Hi @chadwhawkins !
Thanks for the kind words.

With 0.5.0 a bit of restructuring went on, and the original approach of an autouse fixture was replaced by a test-specific setup and teardown step that should restore the original behaviors post-test.

I'm curious what led to the creation of your custom fixture - is it possible that was a workaround due to the autouse fixture misbehaving and its removal should change the need for the custom fixture?

It should be the case that if you pass the plugin's socket_enabled fixture to a test, that should enable the network requests as you wish?

from pytest-socket.

chadwhawkins avatar chadwhawkins commented on June 14, 2024

@miketheman thanks for the reply!

I'm not sure what lead to the creation of the custom fixture as that predates my involvement in the code. Before creating this issue I tried to get socket_enabled to work with no luck. My test setup function looked like this:

def pytest_runtest_setup():
    socket_allow_hosts(allowed=["127.0.0.1", MOTO_RESOURCE_ADDRESS])

However, with a bit more investigation it looks like I need to explicitly disable everything before allowing select hosts, e.g.:

def pytest_runtest_setup():
    disable_socket()
    socket_allow_hosts(allowed=["127.0.0.1", MOTO_RESOURCE_ADDRESS])

I was assuming that allowing only specific hosts implied that all others would be disabled. Just wanted to confirm that's the intended pattern. Thanks!

from pytest-socket.

miketheman avatar miketheman commented on June 14, 2024

@chadwhawkins glad it's working out!
I usually prefer the command-line options pytest ... --disable-socket --socket-allow-hosts="127.0.0.1,..." as a way to not have to use a custom pytest_runtest_setup(), but see that you're using a constant for the moto address, so this approach ought to work in a similar fashion.

Closing this one out!

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.