GithubHelp home page GithubHelp logo

Comments (5)

miketheman avatar miketheman commented on June 13, 2024

Hey @fopinappb ! Thanks for reporting - this is an interesting use case. Do you think that having SocketBlockedError inherit from ConnectionRefusedError instead of RuntimeError would work here?

The original choice of RuntimeError was to raise the issue to the visibility of the operator that they had expressed a test condition without explicitly allowing it.

I was looking for ConnectionRefusedError in tldextract and couldn't find it - could you share where you're seeing that exception raised?

from pytest-socket.

fopinappb avatar fopinappb commented on June 13, 2024

hey @miketheman I've been monkeypatching socket before I found this package (which I prefer now, for main tenability).
I also used a custom RuntimeError at first to easily spot the "unexpected internet usage" but then there were all these packages that used requests or urllib3 in background and handled requests exceptions but not the rest.

And RuntimeError are not supposed to be handled so requests/urllib3 do not indeed..

Switching to ConnectionRefusedError (as an official exception thrown by socket.socket) did sort it out, but I haven't checked exactly where...

For tldextract specifically I believe it's here https://github.com/john-kurkowski/tldextract/blob/0b876fa863bc54fa86c2a4d8b4f58391873e2281/tldextract/suffix_list.py#L33-L34

A RuntimeError won't be a requests exception and won't land there.

Custom subclass of ConnectionRefusedError should work. Can't be sure, but I guess it will land here in requests https://github.com/psf/requests/blob/1466ad713cf84738cd28f1224a7ab4a19e50e361/requests/adapters.py#L497-L498

so any socket error will be handled gracefully

from pytest-socket.

github-actions avatar github-actions commented on June 13, 2024

This issue is stale because it has been open for 90 days with no activity.

from pytest-socket.

github-actions avatar github-actions commented on June 13, 2024

This issue was closed because it has been inactive for 30 days since being marked as stale.

from pytest-socket.

fopinappb avatar fopinappb commented on June 13, 2024

not a good enough point? :)

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.