From 1a3ba0d9c4de856e06f1ce01ed7631843299c2f2 Mon Sep 17 00:00:00 2001 From: JKatzwinkel Date: Thu, 7 Nov 2024 12:25:00 +0100 Subject: [PATCH] Adds test illustrating failed serialization to stdout --- tests/test_document.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_document.py b/tests/test_document.py index 81b0bfeb..9a2e37ae 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1,11 +1,15 @@ import gc +import sys +from pathlib import Path from typing import Final import pytest + from delb import ( CommentNode, Document, DocumentMixinBase, + FormatOptions, ProcessingInstructionNode, TagNode, TextNode, @@ -234,3 +238,19 @@ def test_xpath(files_path): assert page_break.attributes["n"] == "I" assert j == 0 + + +def test_write_to_buffer(result_file: Path) -> None: + doc = Document( + '' + ) + with result_file.open('bw+') as f: + doc.write(f, format_options=FormatOptions(indentation=' ')) + + +def test_write_to_stdout(capsys) -> None: + doc = Document( + '' + ) + doc.write(sys.stdout.buffer, format_options=FormatOptions(indentation=' ')) + assert '' in capsys.readouterr().out