diff --git a/onec_codetemplate_parser/core.py b/onec_codetemplate_parser/core.py index 61c2d52..486d38a 100644 --- a/onec_codetemplate_parser/core.py +++ b/onec_codetemplate_parser/core.py @@ -159,7 +159,7 @@ class Root(Node): for child in self.children: parts.append(",\n") parts.append(child.compile()) - parts.append("\n}") + parts.append("\n}" if self.children else "}") return "".join(parts) def to_files(self, path): diff --git a/tests/conftest.py b/tests/conftest.py index 2b5b714..cacbd94 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,12 +2,28 @@ from pathlib import Path import pytest +import os TEST_FILE = 'Documents/1C/1c-code-templates/Надулич.st' -@pytest.fixture(scope="class", name="test_file_path") -def test_data_path(): - return Path.home() / TEST_FILE +def get_all_test_files(): + """Автоматически находим все файлы в директории""" + st_files = Path(__file__).parent.glob("data/*.st") + list_st_files = [f for f in st_files if f.is_file()] + + list_st_files.append(Path.home()/TEST_FILE) + + env_st_templates = os.getenv("ST_TEMPLATES") + if env_st_templates: + st_templates = Path(env_st_templates) + if st_templates.is_file(): + list_st_files.append(st_templates) + + return [pytest.param(e, id=e.name) for e in list_st_files] + +@pytest.fixture(scope="class", name="test_file_path", params=get_all_test_files()) +def test_data_path(request): + return Path(request.param) @pytest.fixture(scope="class") def test_data(test_file_path): diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 0000000..3ec5925 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True