<s> from unittest import TestCase <EOL> from nose . tools import raises , assert_equal , assert_not_equal <EOL> from wlauto . utils . android import check_output <EOL> from wlauto . utils . misc import merge_dicts , merge_lists , TimeoutError <EOL> from wlauto . utils . types import list_or_integer , list_or_bool , caseless_string , arguments <EOL> class TestCheckOutput ( TestCase ) : <EOL> def test_ok ( self ) : <EOL> check_output ( "<STR_LIT>" , timeout = <NUM_LIT:0.5> , shell = True ) <EOL> @ raises ( TimeoutError ) <EOL> def test_bad ( self ) : <EOL> check_output ( "<STR_LIT>" , timeout = <NUM_LIT:0.5> , shell = True ) <EOL> class TestMerge ( TestCase ) : <EOL> def test_dict_merge ( self ) : <EOL> base = { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : { '<STR_LIT:x>' : <NUM_LIT:9> , '<STR_LIT:z>' : <NUM_LIT:10> } } <EOL> other = { '<STR_LIT:b>' : { '<STR_LIT:x>' : <NUM_LIT:7> , '<STR_LIT:y>' : <NUM_LIT:8> } , '<STR_LIT:c>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } <EOL> result = merge_dicts ( base , other ) <EOL> assert_equal ( result [ '<STR_LIT:a>' ] , <NUM_LIT:1> ) <EOL> assert_equal ( result [ '<STR_LIT:b>' ] [ '<STR_LIT:x>' ] , <NUM_LIT:7> ) <EOL> assert_equal ( result [ '<STR_LIT:b>' ] [ '<STR_LIT:y>' ] , <NUM_LIT:8> ) <EOL> assert_equal ( result [ '<STR_LIT:b>' ] [ '<STR_LIT:z>' ] , <NUM_LIT:10> ) <EOL> assert_equal ( result [ '<STR_LIT:c>' ] , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> def test_merge_dict_lists ( self ) : <EOL> base = { '<STR_LIT:a>' : [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> ] } <EOL> other = { '<STR_LIT:a>' : [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] } <EOL> result = merge_dicts ( base , other ) <EOL> assert_equal ( result [ '<STR_LIT:a>' ] , [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> result = merge_dicts ( base , other , list_duplicates = '<STR_LIT>' ) <EOL> assert_equal ( result [ '<STR_LIT:a>' ] , [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> result = merge_dicts ( base , other , list_duplicates = '<STR_LIT>' ) <EOL> assert_equal ( result [ '<STR_LIT:a>' ] , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> def test_merge_lists ( self ) : <EOL> result = merge_lists ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <NUM_LIT:7> ) <EOL> assert_equal ( result , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:7> ] ) <EOL> result = merge_lists ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <NUM_LIT:1> , duplicates = '<STR_LIT>' ) <EOL> assert_equal ( result , [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ] ) <EOL> @ raises ( ValueError ) <EOL> def test_type_mismatch ( self ) : <EOL> base = { '<STR_LIT:a>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } <EOL> other = { '<STR_LIT:a>' : '<STR_LIT:test>' } <EOL> merge_dicts ( base , other , match_types = True ) <EOL> class TestTypes ( TestCase ) : <EOL> def test_list_or_conversion ( self ) : <EOL> assert_equal ( list_or_integer ( [ <NUM_LIT:1> , '<STR_LIT:2>' , <NUM_LIT:3> ] ) , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> assert_equal ( list_or_integer ( '<STR_LIT>' ) , [ <NUM_LIT:15> , ] ) <EOL> assert_equal ( list_or_bool ( '<STR_LIT:False>' ) , [ False , ] ) <EOL> def test_caseless_string ( self ) : <EOL> cs1 = caseless_string ( '<STR_LIT>' ) <EOL> assert_equal ( cs1 , '<STR_LIT>' ) <EOL> assert_equal ( '<STR_LIT:test>' , cs1 ) <EOL> assert_equal ( cs1 [ <NUM_LIT:0> ] , '<STR_LIT:T>' ) <EOL> assert_not_equal ( cs1 [ <NUM_LIT:0> ] , '<STR_LIT:t>' ) <EOL> assert_not_equal ( cs1 , '<STR_LIT>' ) <EOL> def test_arguments ( self ) : <EOL> assert_equal ( arguments ( '<STR_LIT>' ) , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert_equal ( arguments ( [ '<STR_LIT:test>' , <NUM_LIT> ] ) , [ '<STR_LIT:test>' , '<STR_LIT>' ] ) </s>
