Nicolas Berthier
Nicolas Berthier

Reputation: 508

pyfakefs breaks tests using requests

I have a Pytest test using the pyfakefs fs fixture.

def test_my_unit_test(fs):

    simple_test()

It works as expected and simple tests run with the fake filesystem provided by pyfakefs.

If I run another test that uses requests, I get this error message:

def test_my_unit_test_using_requests(fs):

    test_using_requests()

OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /Users/***/.local/share/virtualenvs/***/lib/python***/site-packages/certifi/cacert.pem

It seems that pyfakefs also generates a fake filesystem for some of Python (or pipenv for that matter) core filesystems breaking requests.

additional_skip_names seems to be the solution for this problem but I can't get it to work. Should it be applied to my test with a parametrized fixture? I have tried this without success:

import pytest
import requests
@pytest.mark.parametrize("fs", [[{"additional_skip_names": requests}]], indirect=True)
def test_my_unit_test(fs):

    test_using_requests()

Upvotes: 0

Views: 190

Answers (0)

Related Questions