<s> """<STR_LIT>""" <EOL> from unittest import TestCase <EOL> from IPython . config . configurable import Configurable <EOL> from IPython . config . application import ( <EOL> Application <EOL> ) <EOL> from IPython . utils . traitlets import ( <EOL> Bool , Unicode , Int , Float , List , Dict <EOL> ) <EOL> class Foo ( Configurable ) : <EOL> i = Int ( <NUM_LIT:0> , config = True , help = "<STR_LIT>" ) <EOL> j = Int ( <NUM_LIT:1> , config = True , help = "<STR_LIT>" ) <EOL> name = Unicode ( '<STR_LIT>' , config = True , help = "<STR_LIT>" ) <EOL> class Bar ( Configurable ) : <EOL> b = Int ( <NUM_LIT:0> , config = True , help = "<STR_LIT>" ) <EOL> enabled = Bool ( True , config = True , help = "<STR_LIT>" ) <EOL> class MyApp ( Application ) : <EOL> name = Unicode ( '<STR_LIT>' ) <EOL> running = Bool ( False , config = True , <EOL> help = "<STR_LIT>" ) <EOL> classes = List ( [ Bar , Foo ] ) <EOL> config_file = Unicode ( '<STR_LIT>' , config = True , <EOL> help = "<STR_LIT>" ) <EOL> aliases = Dict ( { <EOL> '<STR_LIT:i>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> flags = Dict ( dict ( enable = ( { '<STR_LIT>' : { '<STR_LIT>' : True } } , "<STR_LIT>" ) , <EOL> disable = ( { '<STR_LIT>' : { '<STR_LIT>' : False } } , "<STR_LIT>" ) ) ) <EOL> def init_foo ( self ) : <EOL> self . foo = Foo ( config = self . config ) <EOL> def init_bar ( self ) : <EOL> self . bar = Bar ( config = self . config ) <EOL> class TestApplication ( TestCase ) : <EOL> def test_basic ( self ) : <EOL> app = MyApp ( ) <EOL> self . assertEquals ( app . name , '<STR_LIT>' ) <EOL> self . assertEquals ( app . running , False ) <EOL> self . assertEquals ( app . classes , [ MyApp , Bar , Foo ] ) <EOL> self . assertEquals ( app . config_file , '<STR_LIT>' ) <EOL> def test_config ( self ) : <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> config = app . config <EOL> self . assertEquals ( config . Foo . i , <NUM_LIT:10> ) <EOL> self . assertEquals ( config . Foo . j , <NUM_LIT:10> ) <EOL> self . assertEquals ( config . Bar . enabled , False ) <EOL> self . assertEquals ( config . MyApp . log_level , <NUM_LIT:50> ) <EOL> def test_config_propagation ( self ) : <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> app . init_foo ( ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . foo . i , <NUM_LIT:10> ) <EOL> self . assertEquals ( app . foo . j , <NUM_LIT:10> ) <EOL> self . assertEquals ( app . bar . enabled , False ) <EOL> def test_flags ( self ) : <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , False ) <EOL> app . parse_command_line ( [ "<STR_LIT>" ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , True ) <EOL> def test_aliases ( self ) : <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> app . init_foo ( ) <EOL> self . assertEquals ( app . foo . i , <NUM_LIT:5> ) <EOL> app . init_foo ( ) <EOL> self . assertEquals ( app . foo . j , <NUM_LIT:10> ) <EOL> def test_flag_clobber ( self ) : <EOL> """<STR_LIT>""" <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , False ) <EOL> self . assertEquals ( app . bar . b , <NUM_LIT:5> ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , True ) <EOL> self . assertEquals ( app . bar . b , <NUM_LIT:10> ) <EOL> def test_extra_args ( self ) : <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT:args>' ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , False ) <EOL> self . assertEquals ( app . bar . b , <NUM_LIT:5> ) <EOL> self . assertEquals ( app . extra_args , [ '<STR_LIT>' , '<STR_LIT:args>' ] ) <EOL> app = MyApp ( ) <EOL> app . parse_command_line ( [ "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT:args>' ] ) <EOL> app . init_bar ( ) <EOL> self . assertEquals ( app . bar . enabled , True ) <EOL> self . assertEquals ( app . bar . b , <NUM_LIT:5> ) <EOL> self . assertEquals ( app . extra_args , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:args>' ] ) </s>
