Skip to content

Commit 8ebb44d

Browse files
giulio-leoneCopilot
andcommitted
test(docx): reuse backend fixture in msword tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: giulio-leone <giulio97.leone@gmail.com>
1 parent 5e11b37 commit 8ebb44d

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

tests/test_backend_msword.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def get_converter():
4747
return converter
4848

4949

50-
def _make_backend(docx_paths) -> MsWordDocumentBackend:
50+
@pytest.fixture(scope="module")
51+
def backend(docx_paths) -> MsWordDocumentBackend:
5152
docx_path = docx_paths[0]
5253
in_doc = InputDocument(
5354
path_or_stream=docx_path,
@@ -480,9 +481,8 @@ def test_list_counter_and_enum_marker(docx_paths):
480481

481482

482483
def test_handle_equations_in_text_returns_original_text_on_mismatch(
483-
docx_paths, monkeypatch
484+
backend, monkeypatch
484485
):
485-
backend = _make_backend(docx_paths)
486486
element = etree.Element("p")
487487
run = etree.SubElement(element, "r")
488488
text_elem = etree.SubElement(run, "t")
@@ -497,8 +497,7 @@ def test_handle_equations_in_text_returns_original_text_on_mismatch(
497497
assert equations == []
498498

499499

500-
def test_handle_equations_in_text_skips_empty_substrings(docx_paths, monkeypatch):
501-
backend = _make_backend(docx_paths)
500+
def test_handle_equations_in_text_skips_empty_substrings(backend, monkeypatch):
502501
equation = backend.equation_bookends.format(EQ="x")
503502

504503
element = etree.Element("p")
@@ -519,9 +518,8 @@ def test_handle_equations_in_text_skips_empty_substrings(docx_paths, monkeypatch
519518

520519

521520
def test_handle_text_elements_returns_empty_refs_when_text_is_none(
522-
docx_paths, monkeypatch
521+
backend, monkeypatch
523522
):
524-
backend = _make_backend(docx_paths)
525523
element = backend.docx_obj.paragraphs[0]._element
526524

527525
monkeypatch.setattr(
@@ -534,9 +532,8 @@ def test_handle_text_elements_returns_empty_refs_when_text_is_none(
534532

535533

536534
def test_handle_text_elements_heading_defaults_to_non_numbered_when_style_missing(
537-
docx_paths, monkeypatch
535+
backend, monkeypatch
538536
):
539-
backend = _make_backend(docx_paths)
540537
captured: dict[str, tuple[int, str, bool]] = {}
541538

542539
class FakeParagraph:
@@ -568,9 +565,8 @@ def fake_add_heading(doc, level, text, is_numbered_style):
568565

569566

570567
def test_handle_text_elements_inline_equations_stop_when_text_is_consumed(
571-
docx_paths, monkeypatch
568+
backend, monkeypatch
572569
):
573-
backend = _make_backend(docx_paths)
574570
equation_one = backend.equation_bookends.format(EQ="a")
575571
equation_two = backend.equation_bookends.format(EQ="b")
576572

0 commit comments

Comments
 (0)