#NEWLINE# def testResolveDefaults( self ) : #NEWLINE# #INDENT# "A basic test of 'resolveDefaults' utility function." #NEWLINE# s1 = MySubStyle ( value = MySubStyle ( prop = 1.1 ) ) #NEWLINE# s2 = MySubStyle ( value = MySubStyle ( prop = 2.1 , value = { #NEWLINE# #INDENT# 1 : 'a' , #NEWLINE# 2 : 'b' , #NEWLINE# #UNINDENT# } ) , prop = 2 ) #NEWLINE# s3 = MySubStyle ( prop = 3 , value = MySubStyle ( prop = 3.1 , value = MySubStyle ( prop = 3.2 , value = 'abc' ) ) ) #NEWLINE# kw1 = s1 . kwargs ( recursive = True ) #NEWLINE# kw2 = s2 . kwargs ( recursive = True ) #NEWLINE# kw3 = s3 . kwargs ( recursive = False ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw1 ) #NEWLINE# msg = 'Invalid results of resolveDefaults with no subNames and no kwargs.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 9.0 , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( actual , prop = 9 , value = None ) #NEWLINE# msg = 'Invalid results of resolveDefaults with no subNames and kwargs.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw1 , [ 'value' ] ) #NEWLINE# msg = 'Invalid results of resolveDefaults with subNames and no kwargs.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 1.1 , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw1 , [ 'value' ] , prop = 9.0 ) #NEWLINE# msg = 'Invalid results of resolveDefaults with subNames and kwargs.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'value' : 'abc' , #NEWLINE# 'prop' : 5.0 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 2.0 , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw2 , value = { #NEWLINE# #INDENT# 'prop' : 5.0 , #NEWLINE# 'value' : 'abc' , #NEWLINE# #UNINDENT# } ) #NEWLINE# msg = 'Invalid results of resolveDefaults with dict kwarg.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 'value' : { #NEWLINE# #INDENT# 1 : 'a' , #NEWLINE# 2 : 'b' , #NEWLINE# 3 : 'c' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 5.0 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'prop' : 2.0 , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw2 , value = { #NEWLINE# #INDENT# 'prop' : 5.0 , #NEWLINE# 'value' : { #NEWLINE# #INDENT# 3 : 'c' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# msg = 'Invalid results of resolveDefaults with nested dict kwarg.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'prop' : 3.1 , #NEWLINE# 'value' : { #NEWLINE# #INDENT# 'prop' : 3.2 , #NEWLINE# 'value' : 'abc' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw3 , [ 'value' ] ) #NEWLINE# msg = 'Invalid nested resolveDefaults with subNames and no kwargs.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'prop' : 3.0 , #NEWLINE# 'value' : { #NEWLINE# #INDENT# 'prop' : 5.0 , #NEWLINE# 'value' : { #NEWLINE# #INDENT# 'prop' : 10.0 , #NEWLINE# 'value' : ( - 10.0 ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# actual = S . types . lib . resolveDefaults ( kw3 , value = MySubStyle ( prop = 5.0 , value = MySubStyle ( prop = 10.0 , value = ( - 10.0 ) ) ) ) #NEWLINE# msg = 'Invalid nested resolveDefaults with nested dict kwarg.' #NEWLINE# self . assertEqual ( expected , actual , msg = msg )