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:
@@ -34,14 +34,19 @@ def test_data(test_file_path):
|
||||
def temp_src_class(tmp_path_factory):
|
||||
"""
|
||||
Создаёт временную папку 'src' для класса тестов.
|
||||
Папка автоматически удаляется после теста.
|
||||
"""
|
||||
return tmp_path_factory.mktemp("src")
|
||||
|
||||
@pytest.fixture()
|
||||
def temp_src(tmp_path):
|
||||
"""
|
||||
Создаёт временную папку 'src' для теста.
|
||||
Папка автоматически удаляется после теста.
|
||||
Создаёт временную папку 'src' для каждого теста.
|
||||
"""
|
||||
return tmp_path / "src"
|
||||
|
||||
@pytest.fixture()
|
||||
def temp_output_st(tmp_path):
|
||||
"""
|
||||
Создаёт временный файл для вывода каждого теста.
|
||||
"""
|
||||
return tmp_path / "output.st"
|
||||
|
||||
@@ -8,13 +8,14 @@ class Test_API:
|
||||
parse_to_src(str(test_file_path), str(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):
|
||||
def test_render(self, test_file_path, temp_src, tmp_path):
|
||||
"""Тест библиотеки: сборка"""
|
||||
|
||||
parse_to_src(str(test_file_path), str(temp_src))
|
||||
temp_file = tmp_path / "output.st"
|
||||
render_from_src(str(temp_src), str(temp_file))
|
||||
assert temp_file.exists(), f"Файл сборки не создан {temp_file}"
|
||||
assert temp_file.exists(), f"Файл сборки не создан {temp_file}"
|
||||
assert test_file_path.read_text(encoding='utf-8-sig') == temp_file.read_text(encoding='utf-8-sig'), 'Собранный файл не совпадает с исходным'
|
||||
@@ -34,8 +34,9 @@ class Test_CLI:
|
||||
result = runner.invoke(app, ["parse", str(test_file_path), str(temp_src)])
|
||||
assert result.exit_code == 0, result.stdout + result.stderr
|
||||
|
||||
def test_render_command(self, test_file_path, temp_src):
|
||||
def test_render_command(self, test_file_path, temp_src, temp_output_st):
|
||||
"""Тест выполнения команды сборки"""
|
||||
result = runner.invoke(app, ["render", str(test_file_path), str(temp_src)], catch_exceptions=False)
|
||||
runner.invoke(app, ["parse", str(test_file_path), str(temp_src)])
|
||||
result = runner.invoke(app, ["render", str(temp_output_st), str(temp_src)], catch_exceptions=False)
|
||||
assert result.exit_code == 0, result.stdout + result.stderr
|
||||
|
||||
assert test_file_path.read_text(encoding='utf-8-sig') == temp_output_st.read_text(encoding='utf-8-sig'), 'Собранный файл не совпадает с исходным'
|
||||
|
||||
Reference in New Issue
Block a user