Skip to content

Scopes "module" or "class" circumvent the blocking #45

@ymyke

Description

@ymyke

Thanks for the great plugin!

I noticed the following:

Example 1:

import requests

def test():
    requests.get("http://httpbin.org/status/200")

This will raise SocketBlockedError, as expected.

Example 2:

import pytest
import requests

@pytest.fixture # scope == "function" by default
def getit():
    requests.get("http://httpbin.org/status/200")

def test(getit):
    pass

This will also raise the SocketBlockedError. Also as expected.

Example 3:

import pytest
import requests

@pytest.fixture(scope="module") # <== Notice the different scope!
def getit():
    requests.get("http://httpbin.org/status/200")

def test(getit):
    pass

This will pass. No exception.

To me, this was unexpected and lead to some debugging headaches.

Is this intended behavior or a bug? Is there a way to make the plugin also prevent cases such as this one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions