From d23255ad7baca02b88519579ced9e4d9e49b48dc Mon Sep 17 00:00:00 2001 From: krande Date: Thu, 18 Jan 2024 12:13:32 +0100 Subject: [PATCH] remove hardcoded "temp" subdir between work and _dist and _build --- src/paradoc/document.py | 8 ++++---- tests/base_doc/test_table_of_contents.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/paradoc/document.py b/src/paradoc/document.py index e82d590..9fea5b7 100644 --- a/src/paradoc/document.py +++ b/src/paradoc/document.py @@ -68,12 +68,12 @@ def __init__( clean_build_dir=True, create_dirs=False, output_dir=None, - work_dir=None, + work_dir="temp", use_default_html_style=True, **kwargs, ): self.source_dir = pathlib.Path().resolve().absolute() if source_dir is None else pathlib.Path(source_dir) - self.work_dir = pathlib.Path(work_dir).resolve().absolute() if work_dir is not None else pathlib.Path("") + self.work_dir = pathlib.Path(work_dir).resolve().absolute() self.work_dir = self.work_dir.resolve().absolute() self._main_prefix = main_prefix @@ -300,11 +300,11 @@ def app_dir(self): @property def build_dir(self): - return self.work_dir / "temp" / "_build" + return self.work_dir / "_build" @property def dist_dir(self): - return self.work_dir / "temp" / "_dist" + return self.work_dir / "_dist" @property def output_dir(self): diff --git a/tests/base_doc/test_table_of_contents.py b/tests/base_doc/test_table_of_contents.py index 4f0bbbb..2b36a2e 100644 --- a/tests/base_doc/test_table_of_contents.py +++ b/tests/base_doc/test_table_of_contents.py @@ -1,16 +1,23 @@ +import pytest + from paradoc import MY_DOCX_TMPL_BLANK, OneDoc -def test_no_toc(test_dir): - o = OneDoc("temp/no_toc", work_dir=test_dir, create_dirs=True) +@pytest.fixture +def test_output_dir(test_dir): + return test_dir / "toc" + + +def test_no_toc(test_output_dir): + o = OneDoc("temp/no_toc", work_dir=test_output_dir / "no_toc", create_dirs=True) o.compile("no_toc", main_tmpl=MY_DOCX_TMPL_BLANK) -def test_just_toc_has_toc(test_dir): - o = OneDoc("temp/just_toc", work_dir=test_dir, create_dirs=True) +def test_just_toc_has_toc(test_output_dir): + o = OneDoc("temp/just_toc", work_dir=test_output_dir / "just_toc", create_dirs=True) o.compile("just_toc") -def test_has_toc(test_dir, files_dir): - o = OneDoc(files_dir / "toc", work_dir=test_dir, create_dirs=True) +def test_has_toc(test_output_dir, files_dir): + o = OneDoc(files_dir / "toc", work_dir=test_output_dir / "has_toc", create_dirs=True) o.compile("heading_toc_just_toc")