@@ -261,6 +261,10 @@ def __init__(self):
261
261
262
262
def initialize (self , resources , configs ):
263
263
super ().initialize (resources , configs )
264
+ if ("successor" in configs ["test" ] and "test" not in configs ["test" ]):
265
+ raise ProcessorConfigError ('"test" is necessary as the first '
266
+ 'step for "successor" in config '
267
+ 'for test case purpose.' )
264
268
self .initialize_count += 1
265
269
266
270
def _process (self , input_pack : DataPack ):
@@ -274,7 +278,7 @@ def _process(self, input_pack: DataPack):
274
278
@classmethod
275
279
def default_configs (cls ) -> Dict [str , Any ]:
276
280
configs = super ().default_configs ()
277
- configs ['test' ] = "test"
281
+ configs ['test' ] = "test, successor "
278
282
return configs
279
283
280
284
@@ -411,6 +415,20 @@ def test_process_next(self):
411
415
tokens = [token .text for token in pack .get (Token , sentence )]
412
416
self .assertEqual (sent_text , " " .join (tokens ))
413
417
418
+ def test_pipeline_invalid_config (self ):
419
+ # Test a invalid config
420
+ nlp = Pipeline [DataPack ]()
421
+ reader = SentenceReader ()
422
+ nlp .set_reader (reader )
423
+ dummy = DummyPackProcessor ()
424
+ config = {'test' : 'successor' }
425
+ nlp .add (dummy , config = config )
426
+ print (nlp .components )
427
+
428
+ with self .assertRaises (ProcessorConfigError ):
429
+ nlp .initialize ()
430
+
431
+
414
432
def test_pipeline_pack_processor (self ):
415
433
"""Tests a pack processor only."""
416
434
0 commit comments