Skip to content

Commit 58c7ca5

Browse files
author
jingzhi.pang@petuum.com
committed
add a invalid config test
1 parent 795bf36 commit 58c7ca5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/forte/pipeline_test.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ def __init__(self):
261261

262262
def initialize(self, resources, configs):
263263
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.')
264268
self.initialize_count += 1
265269

266270
def _process(self, input_pack: DataPack):
@@ -274,7 +278,7 @@ def _process(self, input_pack: DataPack):
274278
@classmethod
275279
def default_configs(cls) -> Dict[str, Any]:
276280
configs = super().default_configs()
277-
configs['test'] = "test"
281+
configs['test'] = "test, successor"
278282
return configs
279283

280284

@@ -411,6 +415,20 @@ def test_process_next(self):
411415
tokens = [token.text for token in pack.get(Token, sentence)]
412416
self.assertEqual(sent_text, " ".join(tokens))
413417

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+
414432
def test_pipeline_pack_processor(self):
415433
"""Tests a pack processor only."""
416434

0 commit comments

Comments
 (0)