From 3cd443dbe849bf1169f12b16d73a4057960160fb Mon Sep 17 00:00:00 2001 From: Frank Sachsenheim Date: Sun, 19 May 2024 16:03:50 +0200 Subject: [PATCH] Sorts test_document's contents --- tests/test_document.py | 84 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/test_document.py b/tests/test_document.py index 816b326..788bb3b 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -26,41 +26,6 @@ def test_clone(): document.clone() -def test_reduce_whitespace(): - document = Document( - """ - - - I Roy - - <hi>Touting I Self</hi> - - HB 243 A Re - HB 243 B\tRe - - """ - ) - - document.reduce_whitespace() - root = document.root - - assert root.first_child.full_text == "I Roy - Touting I Self" - assert root.css_select("matrix")[0].full_text == "HB 243 A Re" - assert root.css_select("matrix")[1].full_text == "HB 243 B\tRe" - - # - - document = Document( - 'Veröffentlicht im ' - 'Februar 1848.' - ) - document.reduce_whitespace() - assert document.root.full_text == "Veröffentlicht im Februar 1848." - - document = Document("Hello world!") - document.reduce_whitespace() - assert document.root.full_text == "Hello world!" - - def test_contains(): document_a = Document("") document_b = Document("") @@ -113,14 +78,39 @@ class DocumentSubclass(Document): ) -def test_set_root(): - document = Document("") - document.root = document.root[0].detach() - assert str(document) == '' +def test_reduce_whitespace(): + document = Document( + """ + + + I Roy - + <hi>Touting I Self</hi> + + HB 243 A Re + HB 243 B\tRe + + """ + ) - document_2 = Document("parts") - with pytest.raises(ValueError, match="detached node"): - document.root = document_2.root[0] + document.reduce_whitespace() + root = document.root + + assert root.first_child.full_text == "I Roy - Touting I Self" + assert root.css_select("matrix")[0].full_text == "HB 243 A Re" + assert root.css_select("matrix")[1].full_text == "HB 243 B\tRe" + + # + + document = Document( + 'Veröffentlicht im ' + 'Februar 1848.' + ) + document.reduce_whitespace() + assert document.root.full_text == "Veröffentlicht im Februar 1848." + + document = Document("Hello world!") + document.reduce_whitespace() + assert document.root.full_text == "Hello world!" def test_root_siblings(): @@ -153,6 +143,16 @@ def test_root_siblings(): tail_nodes.pop(0) +def test_set_root(): + document = Document("") + document.root = document.root[0].detach() + assert str(document) == '' + + document_2 = Document("parts") + with pytest.raises(ValueError, match="detached node"): + document.root = document_2.root[0] + + def test_xpath(files_path): document = Document(files_path / "tei_marx_manifestws_1848.TEI-P5.xml")