File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,13 @@ def loads(data, conf=True):
478478 index += m .end ()
479479 continue
480480
481+ m = re .compile (r'^\s*types\s*(.*?)\s*{' , re .S ).search (data [index :])
482+ if m :
483+ l = Types (m .group (1 ))
484+ lopen .insert (0 , l )
485+ index += m .end ()
486+ continue
487+
481488 m = re .compile (r'^(\s*)#\s*(.*?)\n' , re .S ).search (data [index :])
482489 if m :
483490 c = Comment (m .group (2 ), inline = '\n ' not in m .group (1 ))
Original file line number Diff line number Diff line change 168168}
169169"""
170170
171+ TESTBLOCK_CASE_10 = """
172+ types {
173+ application/CEA cea;
174+ application/cellml+xml cellml cml;
175+ application/clue_info+xml clue;
176+ application/cms cmsc;
177+ }
178+ """
179+
180+
171181class TestPythonNginx (unittest .TestCase ):
172182 def test_basic_load (self ):
173183 self .assertTrue (nginx .loads (TESTBLOCK_CASE_1 ) is not None )
@@ -272,6 +282,13 @@ def test_semicolon_in_second_key_value(self):
272282 self .assertEqual (location_children [0 ].name , "add_header" )
273283 self .assertEqual (location_children [0 ].value , 'X-XSS-Protection "1;mode-block"' )
274284
285+ def test_types_block (self ):
286+ inp_data = nginx .loads (TESTBLOCK_CASE_10 )
287+ self .assertEqual (len (inp_data .filter ("Types" )), 1 )
288+ self .assertEqual (len (inp_data .filter ("Types" )[0 ].children ), 4 )
289+ self .assertEqual (len (inp_data .filter ("Types" )[0 ].filter ("Key" )), 4 )
290+ data_type = inp_data .filter ("Types" )[0 ].filter ("Key" )[0 ]
291+ self .assertEqual (data_type .value , "cea" )
275292
276293if __name__ == '__main__' :
277294 unittest .main ()
You can’t perform that action at this time.
0 commit comments