CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
793 stars 75 forks source link

disable networking while running tests #180

Closed lsh-0 closed 6 years ago

lsh-0 commented 6 years ago

I just encountered a case where a patched function had been bypassed and was calling out to the internet when it shouldn't be.

I'd like all my tests to run without network access to be honest.

pytest has this: https://github.com/miketheman/pytest-socket

is something similar possible in Green?

CleanCut commented 6 years ago

(Sorry for the delay, I somehow missed this issue when it was posted!)

No, green does not currently have a feature that mocks out socket calls.

If you are interested in contributing a patch to do such a thing, I would be happy to point you to the most likely places in green that you would need to touch. Though, that would likely be more work than writing some code to mock out socket module calls and pasting it at the top of each of your test files.

This is the first time I have heard of such a feature, so my guess is that there isn't a huge demand for it in general.