wrolpi/modules/files/conftest.py

21 lines
569 B
Python

import pathlib
from typing import List, Callable
import pytest
@pytest.fixture
def make_files_structure(test_directory) -> Callable[[List[str]], List[pathlib.Path]]:
def create_files(paths: List[str]) -> List[pathlib.Path]:
files = []
for name in paths:
path = test_directory / name
if name.endswith('/'):
path.mkdir()
else:
path.parent.mkdir(parents=True, exist_ok=True)
path.touch()
files.append(path)
return files
return create_files