From b29b6e7d07c0cf8db066c52344c603ae66ad11c7 Mon Sep 17 00:00:00 2001 From: Vladimir Nadulich Date: Fri, 31 Oct 2025 15:23:24 +0300 Subject: [PATCH] ref --- onec_codetemplate_parser/api.py | 6 ++---- setup.py | 7 ------- tests/conftest.py | 12 +++++++----- tests/test_01.py | 8 +++----- 4 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 setup.py diff --git a/onec_codetemplate_parser/api.py b/onec_codetemplate_parser/api.py index 228e750..d4d2716 100644 --- a/onec_codetemplate_parser/api.py +++ b/onec_codetemplate_parser/api.py @@ -1,9 +1,7 @@ """Программный интерфейс""" -from .core import parser as parser -from .core import Root from pathlib import Path - +from .core import Root, parser def parse_to_src(path: str, src: str): """Парсит шаблон 1С-файла и сохраняет структуру файлов в папку""" @@ -14,4 +12,4 @@ def render_from_src(src: str, path: str): """Генерирует код шаблона из исходников""" root = Root.from_files(src) text = root.compile() - Path(path).write_text(text, encoding='utf-8-sig') \ No newline at end of file + Path(path).write_text(text, encoding='utf-8-sig') diff --git a/setup.py b/setup.py deleted file mode 100644 index 4436a4d..0000000 --- a/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="onec_codetemplate_parser", - version="0.1.0", - packages=find_packages(), -) \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 8041954..8d4d67b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,14 +1,16 @@ -import pytest +"""fixtures for tests""" + from pathlib import Path +import pytest -TEST_FILE = 'Documents/1C/1c-text-tempates/Надулич.st' +TEST_FILE = 'Documents/1C/1c-code-templates/Надулич.st' -@pytest.fixture(scope="class") -def test_file_path(): +@pytest.fixture(scope="class", name="test_file_path") +def test_data_path(): return Path.home() / TEST_FILE @pytest.fixture(scope="class") -def test_data(test_file_path): +def test_data(test_file_path): file_data = test_file_path.read_text(encoding='utf-8-sig') return file_data diff --git a/tests/test_01.py b/tests/test_01.py index f3d5873..844c57d 100644 --- a/tests/test_01.py +++ b/tests/test_01.py @@ -1,7 +1,7 @@ from onec_codetemplate_parser import core from tests.common import check_files_sequential -class Test_Read_Skobkofile: +class TestReadSkobkofile: def test_00_test_file_exist(self, test_file_path): assert test_file_path.exists() @@ -21,7 +21,7 @@ class Test_Read_Skobkofile: assert new_data == test_data -class Test_Write_To_Files: +class TestWriteToFiles: def test_00_to_file(self, test_data, temp_src): root = core.parser(test_data) @@ -35,11 +35,9 @@ class Test_Write_To_Files: # Проверка: есть ли папки dirs = [p for p in temp_src.iterdir() if p.is_dir()] assert len(dirs) == 1 - assert (temp_src / "001.0_Надулич") in dirs + assert temp_src / "001.0_Надулич" in dirs def test_02_sequential_name(self, temp_src): d = temp_src / "001.0_Надулич" / "002.0_Комментарии" subfiles = [p.name for p in d.iterdir()] check_files_sequential(subfiles) - -