#NEWLINE# def testBasic( self ) : #NEWLINE# #INDENT# 'A basic test of Style.' #NEWLINE# style1 = MyStyle ( 'Style #1' ) #NEWLINE# style1 . figure . text . size = 12 #NEWLINE# style1 . axes . text . size = 8 #NEWLINE# style2 = MyStyle ( 'Style #2' ) #NEWLINE# style2 . figure . bgColor = 'grey' #NEWLINE# style2 . axes . bgColor = 'white' #NEWLINE# style3 = MyStyle ( 'Style #3' , parent = style1 ) #NEWLINE# style3 . figure . text . size = 24 #NEWLINE# style4 = MyStyle ( 'Style #4' ) #NEWLINE# style4 . figure . text . size = 24 #NEWLINE# style4 . axes . text . size = 8 #NEWLINE# style4 . figure . bgColor = 'grey' #NEWLINE# style4 . axes . bgColor = 'white' #NEWLINE# style5 = MyStyle ( 'Style #5' ) #NEWLINE# style5 . figure . text . size = 24 #NEWLINE# style5 . figure . bgColor = 'grey' #NEWLINE# style5 . axes . bgColor = 'white' #NEWLINE# style6 = MyStyle ( 'Style #6' , { #NEWLINE# #INDENT# 'figure.text.size' : 24 , #NEWLINE# 'figure.bgColor' : 'grey' , #NEWLINE# 'axes.bgColor' : 'white' , #NEWLINE# #UNINDENT# } ) #NEWLINE# style7 = MyStyle ( 'Style #7' , { #NEWLINE# #INDENT# 'parent' : style1 , #NEWLINE# 'figure.text.size' : 24 , #NEWLINE# #UNINDENT# } ) #NEWLINE# msg = 'Incorrect name' #NEWLINE# self . assertEqual ( 'Style #1' , style1 . name , msg = msg ) #NEWLINE# msg = 'Failed direct access: style1.figure.text.size' #NEWLINE# self . assertEqual ( 12 , style1 . figure . text . size , msg = msg ) #NEWLINE# msg = 'Failed direct access: style3.figure.text.size' #NEWLINE# self . assertEqual ( 24 , style3 . figure . text . size , msg = msg ) #NEWLINE# msg = 'Failed getValue: style1.figure.text.size' #NEWLINE# self . assertEqual ( 12 , style1 . getValue ( 'figure.text.size' ) , msg = msg ) #NEWLINE# msg = 'Failed getValue: style3.figure.text.size' #NEWLINE# self . assertEqual ( 24 , style3 . getValue ( 'figure.text.size' ) , msg = msg ) #NEWLINE# msg = 'Failed getValue: style3.axes.text.size' #NEWLINE# self . assertEqual ( None , style3 . getValue ( 'axes.text.size' ) , msg = msg ) #NEWLINE# msg = 'Failed getResolvedValue: style3.axes.text.size' #NEWLINE# self . assertEqual ( 8 , style3 . getResolvedValue ( 'axes.text.size' ) , msg = msg ) #NEWLINE# newStyle = style3 . resolve ( 'NewStyle' , style2 ) #NEWLINE# self . checkStyleEq ( 'Resolve' , style4 , newStyle ) #NEWLINE# newStyle = style3 . copy ( 'NewStyle' ) #NEWLINE# self . checkStyleEq ( 'Copy' , style3 , newStyle ) #NEWLINE# newStyle . update ( style2 ) #NEWLINE# self . checkStyleEq ( 'Update' , style5 , newStyle ) #NEWLINE# self . checkStyleEq ( 'kwarg CTOR #1' , style5 , style6 ) #NEWLINE# self . checkStyleEq ( 'kwarg CTOR #2' , style3 , style7 ) #NEWLINE# def customFunc( obj ) : #NEWLINE# #INDENT# obj . figureBgColor = 'grey' #NEWLINE# obj . axesBgColor = 'white' #NEWLINE# #UNINDENT# style3 . custom = customFunc #NEWLINE# obj = S . types . Data ( figureTextSize = None , figureTextColor = None , figureBgColor = None , figureFgColor = None , axesTextSize = None , axesTextColor = None , axesBgColor = None , axesFgColor = None ) #NEWLINE# style3 . apply ( obj ) #NEWLINE# self . checkObj ( 'Apply' , obj , style4 ) #NEWLINE# self . assertEqual ( False , style3 . canApply ( obj ) , msg = 'Incorrect return value.' ) #NEWLINE# style1 . setValue ( 'figure.text.size' , 10 ) #NEWLINE# msg = 'Failed setValue: style1.figure.text.size' #NEWLINE# self . assertEqual ( 10 , style1 . getValue ( 'figure.text.size' ) , msg = msg ) #NEWLINE# newStyle = MyStyle . resolveStyles ( None , style1 ) #NEWLINE# self . checkStyleEq ( 'resolveStyles [01]' , style1 , newStyle ) #NEWLINE# newStyle = MyStyle . resolveStyles ( None , [ style2 , style3 ] ) #NEWLINE# self . checkStyleEq ( 'resolveStyles [02]' , style4 , newStyle )