Skip to content

Commit c40f80a

Browse files
committed
Test teardown last
1 parent 081bd69 commit c40f80a

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

tests/test_document.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,35 +188,6 @@ def test_document_variants(
188188
assert len(doc.config["variants"]) == 2
189189

190190

191-
def test_document_teardown(
192-
baker_config: Path,
193-
baker_options: PDFBakerOptions,
194-
doc_dir: Path,
195-
caplog: pytest.LogCaptureFixture,
196-
) -> None:
197-
"""Test document teardown."""
198-
# Create build directory and some files
199-
build_dir = doc_dir / "build" / "test_doc"
200-
build_dir.mkdir(parents=True)
201-
(build_dir / "file1.pdf").write_text("test")
202-
(build_dir / "file2.pdf").write_text("test")
203-
204-
baker = PDFBaker(baker_config, options=baker_options)
205-
doc = PDFBakerDocument(baker, baker.config, doc_dir)
206-
assert doc.config.name == "test_doc"
207-
assert doc.config["pages"] == ["page1.yaml"]
208-
209-
with caplog.at_level(logging.DEBUG):
210-
# Manually reinstall caplog handler to the root logger
211-
logging.getLogger().addHandler(caplog.handler)
212-
doc.teardown()
213-
214-
assert not build_dir.exists()
215-
assert "Tearing down build directory" in caplog.text
216-
assert "Removing files in build directory" in caplog.text
217-
assert "Removing build directory" in caplog.text
218-
219-
220191
def test_document_variants_with_different_pages(
221192
tmp_path: Path, baker_config: Path, baker_options: PDFBakerOptions
222193
) -> None:
@@ -291,3 +262,32 @@ def test_document_variants_with_different_pages(
291262
doc.config.determine_pages(variant2_config)
292263
assert len(doc.config.pages) > 0
293264
assert doc.config.pages[0].name == "page2.yaml"
265+
266+
267+
def test_document_teardown(
268+
baker_config: Path,
269+
baker_options: PDFBakerOptions,
270+
doc_dir: Path,
271+
caplog: pytest.LogCaptureFixture,
272+
) -> None:
273+
"""Test document teardown."""
274+
# Create build directory and some files
275+
build_dir = doc_dir / "build" / "test_doc"
276+
build_dir.mkdir(parents=True)
277+
(build_dir / "file1.pdf").write_text("test")
278+
(build_dir / "file2.pdf").write_text("test")
279+
280+
baker = PDFBaker(baker_config, options=baker_options)
281+
doc = PDFBakerDocument(baker, baker.config, doc_dir)
282+
assert doc.config.name == "test_doc"
283+
assert doc.config["pages"] == ["page1.yaml"]
284+
285+
with caplog.at_level(logging.DEBUG):
286+
# Manually reinstall caplog handler to the root logger
287+
logging.getLogger().addHandler(caplog.handler)
288+
doc.teardown()
289+
290+
assert not build_dir.exists()
291+
assert "Tearing down build directory" in caplog.text
292+
assert "Removing files in build directory" in caplog.text
293+
assert "Removing build directory" in caplog.text

0 commit comments

Comments
 (0)