<s> """<STR_LIT>""" <EOL> import unittest <EOL> from openmdao . main . api import Assembly , Component , set_as_top <EOL> from openmdao . main . datatypes . api import Array , Float , Int , Str , Bool , Enum <EOL> class Oneout ( Component ) : <EOL> """<STR_LIT>""" <EOL> ratio1 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio2 = Int ( <NUM_LIT:9> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio3 = Bool ( True , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio4 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> ratio5 = Str ( '<STR_LIT>' , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio6 = Enum ( <NUM_LIT> , ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT> ) , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> unit = Float ( <NUM_LIT> , units = '<STR_LIT>' , iotype = '<STR_LIT>' ) <EOL> no_unit = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> arrout = Array ( dtype = float , default_value = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> class Oneinp ( Component ) : <EOL> """<STR_LIT>""" <EOL> ratio1 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio2 = Int ( <NUM_LIT:2> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio3 = Bool ( False , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio4 = Float ( <NUM_LIT> , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> ratio5 = Str ( '<STR_LIT>' , iotype = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> ratio6 = Enum ( <NUM_LIT:0> , ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:11> , <NUM_LIT> ) , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> unit = Float ( <NUM_LIT:0.0> , units = '<STR_LIT>' , iotype = '<STR_LIT>' ) <EOL> no_unit = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> arrinp = Array ( dtype = float , default_value = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> class VariableTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , Oneinp ( ) ) <EOL> self . top . add ( '<STR_LIT>' , Oneout ( ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def tearDown ( self ) : <EOL> self . top = None <EOL> def test_undefined_srcexpr_var ( self ) : <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> try : <EOL> self . top . add ( '<STR_LIT:a>' , Assembly ( ) ) <EOL> self . top . a . add ( '<STR_LIT>' , Oneinp ( ) ) <EOL> self . top . a . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> def test_undefined_destexpr_var ( self ) : <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> try : <EOL> self . top . add ( '<STR_LIT:a>' , Assembly ( ) ) <EOL> self . top . a . add ( '<STR_LIT>' , Oneout ( ) ) <EOL> self . top . a . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except AttributeError as err : <EOL> expected = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> def test_var1 ( self ) : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . ratio1 ) <EOL> self . assertEqual ( <NUM_LIT:9> , self . top . oneinp . ratio2 ) <EOL> self . assertEqual ( True , self . top . oneinp . ratio3 ) <EOL> self . assertAlmostEqual ( <NUM_LIT> , self . top . oneinp . ratio4 , <NUM_LIT:5> ) <EOL> self . assertEqual ( '<STR_LIT>' , self . top . oneinp . ratio5 ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . ratio6 ) <EOL> def test_var2 ( self ) : <EOL> self . top . oneout . ratio2 = <NUM_LIT:11> <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . oneout . ratio3 = True <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . ratio1 ) <EOL> self . assertEqual ( True , self . top . oneinp . ratio2 ) <EOL> self . assertEqual ( <NUM_LIT:11> , self . top . oneinp . ratio6 ) <EOL> def test_var3 ( self ) : <EOL> self . top . oneout . ratio3 = False <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> self . assertEqual ( <NUM_LIT:0.0> , self . top . oneinp . ratio1 ) <EOL> self . assertEqual ( False , self . top . oneinp . ratio2 ) <EOL> def test_var3a ( self ) : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . ratio2 ) <EOL> def test_var4 ( self ) : <EOL> self . top . oneout . ratio1 = <NUM_LIT> <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . _setup ( ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" <EOL> self . assertTrue ( msg in str ( err ) ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var5 ( self ) : <EOL> self . top . oneout . ratio1 = <NUM_LIT> <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var6 ( self ) : <EOL> self . top . oneout . ratio1 = <NUM_LIT> <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var7 ( self ) : <EOL> self . top . oneout . ratio2 = <NUM_LIT:20> <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var8 ( self ) : <EOL> self . top . oneout . ratio2 = <NUM_LIT:20> <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var9 ( self ) : <EOL> self . top . oneout . ratio3 = True <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var10 ( self ) : <EOL> self . top . oneout . ratio5 = '<STR_LIT>' <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" <EOL> self . assertTrue ( msg in str ( err ) ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var11 ( self ) : <EOL> self . top . oneout . ratio5 = '<STR_LIT>' <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var12 ( self ) : <EOL> self . top . oneout . ratio5 = '<STR_LIT>' <EOL> try : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_var13_units ( self ) : <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . no_unit ) <EOL> self . assertEqual ( <NUM_LIT> , self . top . oneinp . unit ) <EOL> def _parse_list ( self , liststr ) : <EOL> liststr = liststr [ <NUM_LIT:1> : len ( liststr ) - <NUM_LIT:2> ] <EOL> return set ( [ s . strip ( "<STR_LIT:'>" ) for s in liststr . split ( '<STR_LIT:U+002CU+0020>' ) if s . strip ( ) ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import nose <EOL> import sys <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> nose . runmodule ( ) </s>
