Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] block_network is not working #150

Open
mihalt opened this issue Sep 8, 2024 · 2 comments
Open

[BUG] block_network is not working #150

mihalt opened this issue Sep 8, 2024 · 2 comments

Comments

@mihalt
Copy link

mihalt commented Sep 8, 2024

I see that it works just if I use fixture @pytest.mark.block_network on test without @pytest.mark.vcr. I still have opportunity of go to network then. And even if I manually delete the cassette, it appears again. As I understand, it shouldn't be. I've tried to switch off globaly like

conftest.py

@pytest.fixture(scope="session")
def vcr_config():
    return {
        "block_network": True
    }

or pytest.ini

[pytest]
addopts = --block-network

And tests still can pass in the time when they should fail.

@CarliJoy
Copy link

I guess it would make sense to add a minimal working example. I.e what kind of network lib do you use?

@mihalt
Copy link
Author

mihalt commented Feb 18, 2025

I guess it would make sense to add a minimal working example. I.e what kind of network lib do you use?

The requests mainly. This works. But expected that it will not work

def get_github():
    import requests
    return requests.get("https://github.com/kiwicom/pytest-recording/issues/150#issuecomment-2665135710")

@pytest.mark.block_network
def test_get_github():
    assert get_github().status_code == 200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants