<s> import toolz <EOL> import toolz . curried <EOL> from toolz . curried import ( take , first , second , sorted , merge_with , reduce , <EOL> merge , operator as cop ) <EOL> from collections import defaultdict <EOL> from operator import add <EOL> def test_take ( ) : <EOL> assert list ( take ( <NUM_LIT:2> ) ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) == [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> def test_first ( ) : <EOL> assert first is toolz . itertoolz . first <EOL> def test_merge ( ) : <EOL> assert merge ( factory = lambda : defaultdict ( int ) ) ( { <NUM_LIT:1> : <NUM_LIT:1> } ) == { <NUM_LIT:1> : <NUM_LIT:1> } <EOL> assert merge ( { <NUM_LIT:1> : <NUM_LIT:1> } ) == { <NUM_LIT:1> : <NUM_LIT:1> } <EOL> assert merge ( { <NUM_LIT:1> : <NUM_LIT:1> } , factory = lambda : defaultdict ( int ) ) == { <NUM_LIT:1> : <NUM_LIT:1> } <EOL> def test_merge_with ( ) : <EOL> assert merge_with ( sum ) ( { <NUM_LIT:1> : <NUM_LIT:1> } , { <NUM_LIT:1> : <NUM_LIT:2> } ) == { <NUM_LIT:1> : <NUM_LIT:3> } <EOL> def test_merge_with_list ( ) : <EOL> assert merge_with ( sum , [ { '<STR_LIT:a>' : <NUM_LIT:1> } , { '<STR_LIT:a>' : <NUM_LIT:2> } ] ) == { '<STR_LIT:a>' : <NUM_LIT:3> } <EOL> def test_sorted ( ) : <EOL> assert sorted ( key = second ) ( [ ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) ] ) == [ ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ] <EOL> def test_reduce ( ) : <EOL> assert reduce ( add ) ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) == <NUM_LIT:6> <EOL> def test_module_name ( ) : <EOL> assert toolz . curried . __name__ == '<STR_LIT>' <EOL> def test_curried_operator ( ) : <EOL> for k , v in vars ( cop ) . items ( ) : <EOL> if not callable ( v ) : <EOL> continue <EOL> if not isinstance ( v , toolz . curry ) : <EOL> try : <EOL> v ( <NUM_LIT:1> ) <EOL> except TypeError : <EOL> raise AssertionError ( <EOL> '<STR_LIT>' % k , <EOL> ) <EOL> assert len ( set ( vars ( cop ) ) & set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) == <NUM_LIT:3> </s>
