File tree Expand file tree Collapse file tree 5 files changed +38
-3
lines changed
tests/unit/strictdoc/backend/sdoc Expand file tree Collapse file tree 5 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 185
185
(relations += Reference)
186
186
)?
187
187
188
- section_contents *= SpaceThenRequirement
188
+ section_contents *= SectionOrRequirement
189
189
190
190
'\n'
191
191
'[[/' node_type_close = RequirementType ']]' '\n'
Original file line number Diff line number Diff line change 31
31
)
32
32
from strictdoc .helpers .auto_described import auto_described
33
33
from strictdoc .helpers .cast import assert_cast
34
+ from strictdoc .helpers .exception import StrictDocException
34
35
from strictdoc .helpers .mid import MID
35
36
from strictdoc .helpers .string import ensure_newline
36
37
@@ -121,10 +122,17 @@ def __init__(
121
122
] = parent
122
123
123
124
self .node_type : str = node_type
124
- # FIXME: MERGE NODES
125
+
125
126
if node_type_close is not None and len (node_type_close ) > 0 :
126
- assert node_type == node_type_close
127
+ if node_type != node_type_close :
128
+ raise StrictDocException (
129
+ "[[NODE]] syntax error: "
130
+ "Opening and closing tags must match: "
131
+ f"opening: { node_type } , closing: { node_type_close } ."
132
+ )
127
133
assert is_composite
134
+ else :
135
+ assert not is_composite
128
136
129
137
self .is_composite : bool = is_composite
130
138
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ def get_default_processors(self):
64
64
"SDocSection" : self .process_section ,
65
65
"DocumentFromFile" : self .process_document_from_file ,
66
66
"SDocCompositeNode" : self .process_composite_requirement ,
67
+ "SDocCompositeNodeNew" : self .process_requirement ,
67
68
"SDocNode" : self .process_requirement ,
68
69
"SDocNodeField" : self .process_node_field ,
69
70
}
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ def create(
57
57
+ cls .expand_folder ("dist" , max_depth = 3 )
58
58
+ cls .expand_folder ("tests" , max_depth = 15 )
59
59
+ cls .expand_folder ("output" , max_depth = 15 )
60
+ + cls .expand_folder ("Output" , max_depth = 15 )
60
61
)
61
62
62
63
# Changing typical StrictDoc's own source code files should trigger
Original file line number Diff line number Diff line change 15
15
)
16
16
from strictdoc .backend .sdoc .reader import SDReader
17
17
from strictdoc .backend .sdoc .writer import SDWriter
18
+ from strictdoc .helpers .exception import StrictDocException
18
19
19
20
20
21
def test_001_minimal_doc (default_project_config ):
@@ -964,6 +965,30 @@ def test_089_document_config_use_mid(default_project_config):
964
965
assert input_sdoc == output
965
966
966
967
968
+ def test__validation__30__composite_node_start_end_tags_do_not_match ():
969
+ input_sdoc = """\
970
+ [DOCUMENT]
971
+ TITLE: Test Doc
972
+
973
+ [[REQUIREMENT]]
974
+ UID: TITLE
975
+
976
+ [[/FOOBAR]]
977
+ """ .lstrip ()
978
+
979
+ reader = SDReader ()
980
+
981
+ with pytest .raises (Exception ) as exc_info :
982
+ _ = reader .read (input_sdoc )
983
+
984
+ assert exc_info .type is StrictDocException
985
+ assert exc_info .value .args [0 ] == (
986
+ "[[NODE]] syntax error: "
987
+ "Opening and closing tags must match: "
988
+ "opening: REQUIREMENT, closing: FOOBAR."
989
+ )
990
+
991
+
967
992
def test_edge_case_01_minimal_requirement (default_project_config ):
968
993
input_sdoc = """
969
994
[DOCUMENT]
You can’t perform that action at this time.
0 commit comments