<s> """<STR_LIT>""" <EOL> import unittest <EOL> import warnings <EOL> from six import PY2 <EOL> from openmdao . api import OptionsDictionary <EOL> class TestOptions ( unittest . TestCase ) : <EOL> def test_options_dictionary ( self ) : <EOL> self . options = OptionsDictionary ( ) <EOL> with self . assertRaises ( KeyError ) as cm : <EOL> self . options [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' . format ( '<STR_LIT>' ) , str ( cm . exception ) ) <EOL> self . options . add_option ( '<STR_LIT>' , <NUM_LIT> ) <EOL> self . assertEqual ( self . options [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> if PY2 : <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> else : <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> self . options . add_option ( '<STR_LIT>' , <NUM_LIT:0> , values = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> for value in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] : <EOL> self . options [ '<STR_LIT>' ] = value <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options [ '<STR_LIT>' ] = <NUM_LIT:4> <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> self . options . add_option ( '<STR_LIT>' , True ) <EOL> self . options [ '<STR_LIT>' ] = True <EOL> self . options [ '<STR_LIT>' ] = False <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> if PY2 : <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> else : <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> self . options . add_option ( '<STR_LIT>' , <NUM_LIT:10> , lower = <NUM_LIT:0> , upper = <NUM_LIT:10> ) <EOL> for value in range ( <NUM_LIT:0> , <NUM_LIT:11> ) : <EOL> self . options [ '<STR_LIT>' ] = value <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options [ '<STR_LIT>' ] = <NUM_LIT:15> <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options [ '<STR_LIT>' ] = - <NUM_LIT:1> <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> with self . assertRaises ( ValueError ) as cm : <EOL> self . options . maxiter = - <NUM_LIT:1> <EOL> self . assertEqual ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> self . assertTrue ( '<STR_LIT>' in self . options ) <EOL> self . options . remove_option ( '<STR_LIT>' ) <EOL> self . assertFalse ( '<STR_LIT>' in self . options ) <EOL> self . options . _add_deprecation ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> warnings . simplefilter ( "<STR_LIT>" ) <EOL> self . options [ '<STR_LIT>' ] = <NUM_LIT:5> <EOL> self . assertEqual ( len ( w ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( str ( w [ <NUM_LIT:0> ] . message ) , <EOL> "<STR_LIT>" ) <EOL> def test_locking ( self ) : <EOL> opt1 = OptionsDictionary ( ) <EOL> opt1 . add_option ( '<STR_LIT>' , <NUM_LIT> , lock_on_setup = True ) <EOL> opt2 = OptionsDictionary ( ) <EOL> opt2 . add_option ( '<STR_LIT>' , <NUM_LIT> , lock_on_setup = True ) <EOL> opt1 [ '<STR_LIT>' ] = <NUM_LIT> <EOL> opt2 [ '<STR_LIT>' ] = <NUM_LIT> <EOL> OptionsDictionary . locked = True <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> opt1 [ '<STR_LIT>' ] = <NUM_LIT> <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> opt2 [ '<STR_LIT>' ] = <NUM_LIT> <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
