refactor(testing.pytest): change mock_pkg interface
being more explicit about what the fixture provides as an output, instead of solely describing the site effects. Also the consumer is now responsible for the module directory layout.
This commit is contained in:
parent
e6bf657919
commit
aa2540cf3f
2 changed files with 28 additions and 19 deletions
|
|
@ -6,7 +6,10 @@ import pytest
|
|||
pytestmark = pytest.mark.pytest
|
||||
|
||||
from byteb4rb1e.testing.pytest.decorators import run_in_subprocess_once
|
||||
from byteb4rb1e.testing.pytest.fixtures import current_test, mock_pkg
|
||||
from byteb4rb1e.testing.pytest.fixtures import (
|
||||
current_test,
|
||||
mock_system_site_package_dir
|
||||
)
|
||||
|
||||
|
||||
def test_current_test(current_test):
|
||||
|
|
@ -19,14 +22,16 @@ def test_current_test(current_test):
|
|||
|
||||
|
||||
@run_in_subprocess_once()
|
||||
def test_mock_pkg(mock_pkg):
|
||||
def test_mock_system_site_package_dir(mock_system_site_package_dir):
|
||||
"""
|
||||
"""
|
||||
dummy_data = 'Hello'
|
||||
|
||||
mock_pkg('foobarpkg', {
|
||||
'data.txt': dummy_data
|
||||
})
|
||||
pkgdir = mock_system_site_package_dir('foobarpkg')
|
||||
|
||||
(pkgdir / 'data.txt').write_text(dummy_data)
|
||||
|
||||
assert (pkgdir / '__init__.py').exists()
|
||||
|
||||
result = next(importlib.resources.files('foobarpkg').glob('data.txt')).read_text()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue