Files
md_to_gost/tests/test_page_geometry.py
T
Igor20264 1a5b35eb54
Python application / build (push) Has been cancelled
BigUpdate 0.5.0
- add Local Render Mermaid
- add page-starе для указания смещения страниц
- add Гиперссылки в документе на списки литературы
2026-09-07 09:54:33 +03:00

36 lines
1.1 KiB
Python

"""Page number start / offset helpers."""
from docx import Document
from docx.oxml.ns import qn
from md2gost.page_geometry import apply_page_number_start, set_section_page_start
def test_set_section_page_start():
doc = Document()
section = doc.sections[0]
set_section_page_start(section, 3)
pg = section._sectPr.find(qn("w:pgNumType"))
assert pg is not None
assert pg.get(qn("w:start")) == "3"
def test_apply_page_number_start_skips_front():
doc = Document()
doc.add_section() # front
doc.add_section() # body
apply_page_number_start(doc, 2, front_sections=1)
front = doc.sections[0]._sectPr.find(qn("w:pgNumType"))
body = doc.sections[1]._sectPr.find(qn("w:pgNumType"))
assert front is None or front.get(qn("w:start")) is None
assert body is not None
assert body.get(qn("w:start")) == "2"
def test_apply_page_number_start_none_strips():
doc = Document()
set_section_page_start(doc.sections[0], 5)
apply_page_number_start(doc, None)
pg = doc.sections[0]._sectPr.find(qn("w:pgNumType"))
assert pg is None or pg.get(qn("w:start")) is None