feat(testing.pytest): add pkg mock fixture

This commit is contained in:
Tiara Rodney 2025-06-21 00:32:07 +02:00
parent 43cdf21d4b
commit 24806959bb
No known key found for this signature in database
GPG key ID: 5F43FAB4FBE5B5EB
2 changed files with 45 additions and 2 deletions

View file

@ -1,10 +1,12 @@
from pathlib import Path
import importlib.resources
import pytest
pytestmark = pytest.mark.pytest
from byteb4rb1e.utils.testing.pytest.fixtures import current_test
from byteb4rb1e.utils.testing.pytest.decorators import run_in_subprocess_once
from byteb4rb1e.utils.testing.pytest.fixtures import current_test, mock_pkg
def test_current_test(current_test):
@ -14,3 +16,18 @@ def test_current_test(current_test):
assert str(Path(__file__)) == str(suite_path)
assert case_name == "test_current_test"
@run_in_subprocess_once()
def test_mock_pkg(mock_pkg):
"""
"""
dummy_data = 'Hello'
mock_pkg('foobarpkg', {
'data.txt': dummy_data
})
result = next(importlib.resources.files('foobarpkg').glob('data.txt')).read_text()
assert result == dummy_data