tech-bid-manage20260423A/tests/test_parse_outline.py
2026-04-23 17:10:38 +08:00

25 lines
925 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""大纲解析1.1 类编号不得被误拆成一级 1 与 title '.1 标题'"""
import unittest
from modules.generator import _parse_outline
class TestParseOutline(unittest.TestCase):
def test_11_stays_single_section(self):
text = "某某项目标书标题\n1.1 沟槽开挖与支护\n1.2 排降水\n"
_, sections, _ = _parse_outline(text)
self.assertEqual(len(sections), 2, [s.get('number') for s in sections])
for s in sections:
if s.get('level') == 1:
self.assertFalse(
(s.get('title') or '').lstrip().startswith('.'),
'不得出现一级章节 title 以 .1 开头(误将 1.1 拆成 1 与 .1 标题)',
)
titles = ' '.join(s['title'] for s in sections)
self.assertIn('沟槽', titles)
self.assertIn('排降', titles)
if __name__ == '__main__':
unittest.main()