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.
38 lines
877 B
Python
38 lines
877 B
Python
from pathlib import Path
|
|
import importlib.resources
|
|
|
|
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_system_site_package_dir
|
|
)
|
|
|
|
|
|
def test_current_test(current_test):
|
|
"""
|
|
"""
|
|
suite_path, case_name = current_test
|
|
|
|
assert str(Path(__file__)) == str(suite_path)
|
|
assert case_name == "test_current_test"
|
|
|
|
|
|
@run_in_subprocess_once()
|
|
def test_mock_system_site_package_dir(mock_system_site_package_dir):
|
|
"""
|
|
"""
|
|
dummy_data = 'Hello'
|
|
|
|
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()
|
|
|
|
assert result == dummy_data
|