You've already forked onec_codetemplate_parser
mirror of
https://github.com/240596448/onec_codetemplate_parser.git
synced 2025-11-23 21:34:39 +02:00
проблема наборов
This commit is contained in:
@@ -31,9 +31,17 @@ def test_data(test_file_path):
|
||||
return file_data
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def temp_src(tmp_path_factory):
|
||||
def temp_src_class(tmp_path_factory):
|
||||
"""
|
||||
Создаёт временную папку 'src' для класса тестов.
|
||||
Папка автоматически удаляется после теста.
|
||||
"""
|
||||
return tmp_path_factory.mktemp("src")
|
||||
|
||||
@pytest.fixture()
|
||||
def temp_src(tmp_path):
|
||||
"""
|
||||
Создаёт временную папку 'src' для теста.
|
||||
Папка автоматически удаляется после теста.
|
||||
"""
|
||||
return tmp_path_factory.mktemp("src")
|
||||
return tmp_path / "src"
|
||||
|
||||
@@ -6,8 +6,11 @@ class Test_API:
|
||||
def test_parse(self, test_file_path, temp_src):
|
||||
"""Тест библиотеки: парсинг"""
|
||||
parse_to_src(str(test_file_path), str(temp_src))
|
||||
assert folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
|
||||
assert folder_contains_files(temp_src), f"В папке нет ни одного файла {temp_src}"
|
||||
if test_file_path.stat().st_size > 6:
|
||||
assert folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
|
||||
assert folder_contains_files(temp_src), f"В папке нет ни одного файла {temp_src}"
|
||||
else:
|
||||
assert not folder_is_empty(temp_src), f"Для пустого файла что-то распарсилось {temp_src}"
|
||||
|
||||
def test_render(self, temp_src, tmp_path):
|
||||
"""Тест библиотеки: сборка"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from onec_codetemplate_parser import core
|
||||
from tests.common import check_files_sequential
|
||||
from tests.common import check_files_sequential, folder_is_empty, folder_contains_files
|
||||
|
||||
class TestReadSkobkofile:
|
||||
|
||||
@@ -23,21 +23,19 @@ class TestReadSkobkofile:
|
||||
|
||||
class TestWriteToFiles:
|
||||
|
||||
def test_00_to_file(self, test_data, temp_src):
|
||||
def test_white_to_src(self, test_data, temp_src):
|
||||
root = core.parser(test_data)
|
||||
root.to_files(temp_src)
|
||||
|
||||
def test_01_to_files(self, temp_src):
|
||||
# Проверка: есть ли файлы
|
||||
files = [p for p in temp_src.iterdir() if p.is_file()]
|
||||
assert len(files) == 0
|
||||
# assert folder_contains_files(temp_src), f"В папке нет ни одного файла {temp_src}"
|
||||
# assert not folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
|
||||
|
||||
# Проверка: есть ли папки
|
||||
dirs = [p for p in temp_src.iterdir() if p.is_dir()]
|
||||
assert len(dirs) == 1
|
||||
assert temp_src / "001.0_Надулич" in dirs
|
||||
assert len(dirs) == 1, f"Ожидалась 1 папка в src, получили {len(dirs)}"
|
||||
assert temp_src / "001.0_Надулич" in dirs, f"Папка 001.0_Надулич не найдена в {temp_src}"
|
||||
|
||||
def test_02_sequential_name(self, temp_src):
|
||||
def test_sequential_name(self, temp_src):
|
||||
d = temp_src / "001.0_Надулич" / "002.0_Комментарии"
|
||||
subfiles = [p.name for p in d.iterdir()]
|
||||
check_files_sequential(subfiles)
|
||||
|
||||
Reference in New Issue
Block a user