diff --git a/.gitignore b/.gitignore index 49e14ccc8d..5bb0f64707 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ venv*/ .python-version build/ dist/ +.idea/ diff --git a/requirements.txt b/requirements.txt index 0d8ba2eff0..48360c8206 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,3 +28,4 @@ trio-typing==0.10.0 trustme==1.1.0; python_version < '3.9' trustme==1.2.0; python_version >= '3.9' uvicorn==0.32.1 +blockbuster==1.5.10 diff --git a/tests/conftest.py b/tests/conftest.py index 858bca1397..f50edc4db4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,7 @@ import pytest import trustme +from blockbuster import blockbuster_ctx from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import ( BestAvailableEncryption, @@ -31,6 +32,13 @@ } +@pytest.fixture(autouse=True) +def blockbuster(): + with blockbuster_ctx() as bb: + bb.functions["os.stat"].can_block_in("/mimetypes.py", "init") + yield bb + + @pytest.fixture(scope="function", autouse=True) def clean_environ(): """Keeps os.environ clean for every test without having to mock os.environ""" diff --git a/tests/models/test_whatwg.py b/tests/models/test_whatwg.py index 14af682586..8f3fa2b0a0 100644 --- a/tests/models/test_whatwg.py +++ b/tests/models/test_whatwg.py @@ -3,6 +3,7 @@ # https://url.spec.whatwg.org/ import json +from pathlib import Path import pytest @@ -10,7 +11,8 @@ # URL test cases from... # https://github.com/web-platform-tests/wpt/blob/master/url/resources/urltestdata.json -with open("tests/models/whatwg.json", "r", encoding="utf-8") as input: +whatwg_path = Path(__file__).parent.parent / "models" / "whatwg.json" +with whatwg_path.open("r", encoding="utf-8") as input: test_cases = json.load(input) test_cases = [ item