<s> import pickle <EOL> from nose . tools import eq_ <EOL> from . . import extractors <EOL> from ... . dependencies import solve <EOL> from ... datasource import Datasource <EOL> def return_foo ( ) : <EOL> return "<STR_LIT:foo>" <EOL> segments = Datasource ( "<STR_LIT>" ) <EOL> text = Datasource ( "<STR_LIT:text>" ) <EOL> text_extractor = extractors . regex ( [ "<STR_LIT>" , "<STR_LIT>" ] , text , <EOL> name = "<STR_LIT>" ) <EOL> segment_extractor = extractors . regex ( [ "<STR_LIT>" , "<STR_LIT>" ] , segments , <EOL> name = "<STR_LIT>" ) <EOL> def test_text_extractor ( ) : <EOL> cache = { text : "<STR_LIT>" } <EOL> eq_ ( solve ( text_extractor , cache = cache ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> cache = { text : None } <EOL> eq_ ( solve ( text_extractor , cache = cache ) , [ ] ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( text_extractor ) ) , text_extractor ) <EOL> def test_segment_extractor ( ) : <EOL> cache = { segments : [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT:foo>" ] } <EOL> eq_ ( solve ( segment_extractor , cache = cache ) , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( segment_extractor ) ) , segment_extractor ) </s>
