<s> import pickle <EOL> from nose . tools import eq_ <EOL> from ... . . datasources import revision_oriented <EOL> from ... . . dependencies import solve <EOL> from . . dictionary import Dictionary <EOL> calvins_words = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } <EOL> def dictionary_check ( word ) : <EOL> return word . lower ( ) in calvins_words <EOL> my_dict = Dictionary ( "<STR_LIT>" , dictionary_check ) <EOL> r_text = revision_oriented . revision . text <EOL> p_text = revision_oriented . revision . parent . text <EOL> def test_dictionary ( ) : <EOL> cache = { p_text : "<STR_LIT>" , <EOL> r_text : "<STR_LIT>" } <EOL> eq_ ( solve ( my_dict . revision . datasources . dict_words , cache = cache ) , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> eq_ ( solve ( my_dict . revision . parent . datasources . dict_words , cache = cache ) , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> eq_ ( solve ( my_dict . revision . datasources . dict_word_frequency , cache = cache ) , <EOL> { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> eq_ ( solve ( my_dict . revision . datasources . non_dict_word_frequency , <EOL> cache = cache ) , <EOL> { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> eq_ ( solve ( my_dict . revision . parent . datasources . dict_word_frequency , <EOL> cache = cache ) , <EOL> { '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> eq_ ( solve ( my_dict . revision . parent . datasources . non_dict_word_frequency , <EOL> cache = cache ) , <EOL> { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> diff = my_dict . revision . diff <EOL> eq_ ( solve ( diff . datasources . dict_word_delta , cache = cache ) , <EOL> { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : - <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> pd = solve ( diff . datasources . dict_word_prop_delta , cache = cache ) <EOL> eq_ ( pd . keys ( ) , { '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' } ) <EOL> eq_ ( round ( pd [ '<STR_LIT>' ] , <NUM_LIT:2> ) , <NUM_LIT> ) <EOL> eq_ ( round ( pd [ '<STR_LIT>' ] , <NUM_LIT:2> ) , - <NUM_LIT:1> ) <EOL> eq_ ( round ( pd [ '<STR_LIT>' ] , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> pd = solve ( diff . datasources . non_dict_word_prop_delta , cache = cache ) <EOL> eq_ ( pd . keys ( ) , { '<STR_LIT>' } ) <EOL> eq_ ( round ( pd [ '<STR_LIT>' ] , <NUM_LIT:2> ) , - <NUM_LIT:1> ) <EOL> eq_ ( solve ( my_dict . revision . dict_words , cache = cache ) , <NUM_LIT:5> ) <EOL> eq_ ( solve ( my_dict . revision . parent . dict_words , cache = cache ) , <NUM_LIT:4> ) <EOL> eq_ ( solve ( my_dict . revision . non_dict_words , cache = cache ) , <NUM_LIT:5> ) <EOL> eq_ ( solve ( my_dict . revision . parent . non_dict_words , cache = cache ) , <NUM_LIT:6> ) <EOL> eq_ ( solve ( diff . dict_word_delta_sum , cache = cache ) , <NUM_LIT:1.0> ) <EOL> eq_ ( solve ( diff . dict_word_delta_increase , cache = cache ) , <NUM_LIT:2> ) <EOL> eq_ ( solve ( diff . dict_word_delta_decrease , cache = cache ) , - <NUM_LIT:1> ) <EOL> eq_ ( solve ( diff . non_dict_word_delta_sum , cache = cache ) , - <NUM_LIT:1> ) <EOL> eq_ ( solve ( diff . non_dict_word_delta_increase , cache = cache ) , <NUM_LIT:0> ) <EOL> eq_ ( solve ( diff . non_dict_word_delta_decrease , cache = cache ) , - <NUM_LIT:1> ) <EOL> eq_ ( round ( solve ( diff . dict_word_prop_delta_sum , cache = cache ) , <NUM_LIT:2> ) , <NUM_LIT> ) <EOL> eq_ ( round ( solve ( diff . dict_word_prop_delta_increase , cache = cache ) , <NUM_LIT:2> ) , <NUM_LIT> ) <EOL> eq_ ( round ( solve ( diff . dict_word_prop_delta_decrease , cache = cache ) , <NUM_LIT:2> ) , - <NUM_LIT:1> ) <EOL> eq_ ( round ( solve ( diff . non_dict_word_prop_delta_sum , cache = cache ) , <NUM_LIT:2> ) , - <NUM_LIT:1> ) <EOL> eq_ ( round ( solve ( diff . non_dict_word_prop_delta_increase , cache = cache ) , <NUM_LIT:2> ) , <EOL> <NUM_LIT:0> ) <EOL> eq_ ( round ( solve ( diff . non_dict_word_prop_delta_decrease , cache = cache ) , <NUM_LIT:2> ) , <EOL> - <NUM_LIT:1> ) <EOL> def test_pickling ( ) : <EOL> eq_ ( pickle . loads ( pickle . dumps ( my_dict . revision . dict_words ) ) , <EOL> my_dict . revision . dict_words ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( my_dict . revision . parent . dict_words ) ) , <EOL> my_dict . revision . parent . dict_words ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( my_dict . revision . non_dict_words ) ) , <EOL> my_dict . revision . non_dict_words ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( my_dict . revision . parent . non_dict_words ) ) , <EOL> my_dict . revision . parent . non_dict_words ) <EOL> diff = my_dict . revision . diff <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_delta_sum ) ) , <EOL> diff . dict_word_delta_sum ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_delta_increase ) ) , <EOL> diff . dict_word_delta_increase ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_delta_decrease ) ) , <EOL> diff . dict_word_delta_decrease ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_delta_sum ) ) , <EOL> diff . non_dict_word_delta_sum ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_delta_increase ) ) , <EOL> diff . non_dict_word_delta_increase ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_delta_decrease ) ) , <EOL> diff . non_dict_word_delta_decrease ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_prop_delta_sum ) ) , <EOL> diff . dict_word_prop_delta_sum ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_prop_delta_increase ) ) , <EOL> diff . dict_word_prop_delta_increase ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . dict_word_prop_delta_decrease ) ) , <EOL> diff . dict_word_prop_delta_decrease ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_prop_delta_sum ) ) , <EOL> diff . non_dict_word_prop_delta_sum ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_prop_delta_increase ) ) , <EOL> diff . non_dict_word_prop_delta_increase ) <EOL> eq_ ( pickle . loads ( pickle . dumps ( diff . non_dict_word_prop_delta_decrease ) ) , <EOL> diff . non_dict_word_prop_delta_decrease ) </s>
