def testBasic( self ):

      mgr = MyStyleManager()

      style1 = mgr.create( 'Style #1' )
      style1.figure.text.size = 12
      style1.axes.text.size = 8

      style2 = mgr.create( 'Style #2', 
                           { 'figure.bgColor' : 'grey', 
                             'axes.bgColor' : 'white' } )
      style2.figure.bgColor = 'grey'
      style2.axes.bgColor = 'white'

      style3 = mgr.create( 'Style #3', parent = style1 )
      style3.figure.text.size = 24

      # Resolved 3 with 2
      style4 = MyStyle( 'Style #4' )
      style4.figure.text.size = 24
      style4.axes.text.size = 8
      style4.figure.bgColor = 'grey'
      style4.axes.bgColor = 'white'

      # Resolved 3 with 2 and updated 3
      style5 = mgr.create( 'Style #5' )
      mgr[ 'Style #5' ].figure.text.size = 16
      mgr[ 'Style #5' ].axes.text.size = 8
      mgr[ 'Style #5' ].figure.bgColor = 'grey'
      mgr[ 'Style #5' ].axes.bgColor = 'white'

      style6 = mgr.create( 'Style #6', parent='Style #5' )
      style6.figure.text.color = 'orange'
      style6.axes.text.color = 'purple'

      # Copy tests
      newStyle = mgr.copy( style3, 'NewStyle1' )
      self.checkStyleEq( 'Copy by style', style3, newStyle )

      newStyle = mgr.copy( 'Style #3', 'NewStyle2' )
      self.checkStyleEq( 'Copy by name', style3, newStyle )

      self.assertRaises( Exception, mgr.copy, 'badName', 'blah',
                   msg = "Failed to raise when copying a non-existant style." )

      # Test Resolve
      resolvedStyle = mgr.resolve( "Resolved Style #1", 'Style #2' )
      self.checkStyleEq( 'Resolve by name', style2, resolvedStyle )
      mgr.erase( resolvedStyle )

      resolvedStyle = mgr.resolve( "Resolved Style #2",
                                   ['Style #2', style3, 'blah'],
                                   ignoreNotFound = True )
      self.checkStyleEq( 'Resolve by list', style4, resolvedStyle )
      mgr.erase( resolvedStyle )

      self.assertRaises( Exception, mgr.resolve, None, 'does not exist',
                   msg = "Resolve failed to throw on invalid style." )

      # Apply testing
      def customFunc( obj ):
         obj.figureBgColor = 'grey'
         obj.axesBgColor = 'white'

      style3.custom = customFunc

      obj = S.types.Data(
         figureTextSize = None,
         figureTextColor = None,
         figureBgColor = None,
         figureFgColor = None,
         axesTextSize = None,
         axesTextColor = None,
         axesBgColor = None,
         axesFgColor = None,
      )

      mgr.apply( obj, style4 )
      self.checkObj( 'Apply by style', obj, style4 )
      self.assertEqual( True, mgr.exists(style4),
               msg = "Failed to auto add an applied style." )

      obj = S.types.Data(
         figureTextSize = None,
         figureTextColor = None,
         figureBgColor = None,
         figureFgColor = None,
         axesTextSize = None,
         axesTextColor = None,
         axesBgColor = None,
         axesFgColor = None,
      )

      self.assertRaises( Exception, mgr.apply, obj, 'invalidName',
                   msg = "Failed to raise on applying a bad style." )

      self.assertEqual( [], mgr.getElementStyles( obj ),
               msg = "Element styles should be []." )

      mgr.apply( obj, 'Style #3' )
      self.checkObj( 'Apply by name', obj, style4 )

      style3.figure.text.size = 16
      mgr.reapply()
      self.checkObj( 'Re-Apply', obj, style5 )

      mgr.set( obj, 'figure.text.size', 24 )
      self.checkObj( 'Set by name', obj, style4 )

      mgr.set( obj, { 'figure.text.size' : 16 } )
      self.checkObj( 'Set by dict', obj, style5 )

      self.assertRaises( Exception, mgr.set, obj, { 'foo' : 1 }, 1,
                   msg = "Failed to throw with invalid 'set' parameters." )

      # Check the get/set of the element tag
      obj = S.types.Data(
         figureTextSize = None,
         figureTextColor = None,
         figureBgColor = None,
         figureFgColor = None,
         axesTextSize = None,
         axesTextColor = None,
         axesBgColor = None,
         axesFgColor = None,
      )
      mgr.apply( obj, style5 )

      self.assertEqual( [], mgr.getTags( obj ),
               msg = "Element name should be None" )

      mgr.untag( obj, 'testTag' )
      self.assertEqual( False, mgr.hasTag( obj, 'testTag' ),
               msg = "Incorrect result for hasTag (when nothing set)." )
      mgr.tag( obj, 'testTag' )
      self.assertEqual( ['testTag'], mgr.getTags( obj ),
               msg = "Set/get tag failed for obj" )
      self.assertEqual( True, mgr.hasTag( obj, 'testTag' ),
               msg = "Incorrect result for hasTag (when it has it)" )
      mgr.untag( obj, 'testTag' )
      self.assertEqual( False, mgr.hasTag( obj, 'testTag' ),
               msg = "Incorrect result for hasTag (when it doesn't have it)" )
      mgr.tag( obj, 'testTag' )

      tagStyle = MyStyle( 'TagStyle' )
      tagStyle.figure.text.color = 'orange'
      tagStyle.axes.text.color = 'purple'

      mgr.apply( obj, tagStyle, tag = "OtherTag" )
      self.checkObj( 'Set by incorrect tag', obj, style5 )

      mgr.apply( obj, tagStyle, tag = "testTag" )
      self.checkObj( 'Set by correct tag', obj, style6 )

      # Check apply by tag only
      obj = S.types.Data(
         figureTextSize = None,
         figureTextColor = None,
         figureBgColor = None,
         figureFgColor = None,
         axesTextSize = None,
         axesTextColor = None,
         axesBgColor = None,
         axesFgColor = None,
      )
      mgr.tag( obj, 'applyTestTag' )
      mgr.apply( None, style6, tag = 'applyTestTag' )
      self.checkObj( 'Apply by tag', obj, style6 )

      # Verify that the new style will be added when resolve is called
      tmpStyle1 = MyStyle( 'TmpStyle #1' )
      mgr.resolve( None, tmpStyle1 )

      # Verify that the new style will be added when create is called
      tmpStyle2 = MyStyle( 'TmpStyle #2' )
      mgr.create( None, parent = tmpStyle2 )

      # check loading / clearing styles
      expected = [ 'NewStyle1', 'NewStyle2', 'Style #1', 'Style #2',
                   'Style #3', 'Style #4', 'Style #5', 'Style #6',
                   'TagStyle', 'TmpStyle #1', 'TmpStyle #2' ]
      self.assertEqual( expected, mgr.getAll(),
               msg = "Invalid list of loaded styles." )

      tmpfile = open( os.path.join( self.outputDir, "warning-output.log" ),
                      'w' )
      mgr.apply( obj, [ style1, 'Style #3' ] )
      mgr.erase( style3 )
      mgr.reapply()
      tmpfile.close()

      mgr.clear()
      expected = []
      self.assertEqual( expected, mgr.getAll(),
               msg = "mgr shows styles loaded, when should be empty." )

      tmpStyle = MyStyle( "Temp Style" )
      mgr.add( tmpStyle )
      self.assertRaises( Exception, mgr.add, tmpStyle,
                   msg = "Failed to throw on multiple adds." )

      mgr.erase( tmpStyle )
      result = mgr.find( tmpStyle.name )
      self.assertEqual( None, result,
               msg = "Did not remove 'tmpStyle' from the manager." )

      msg = "Failed to throw on multiple removes."
      self.assertRaises( Exception, mgr.erase, tmpStyle, msg = msg )

      msg = "Failed to throw with invalid parent"
      self.assertRaises( Exception, mgr.create, 'Bad Parent', parent = "Bogus", msg = msg )

   #-----------------------------------------------------------------------
A basic test of StyleManager.
dataset/ETHPy150Open nasa/mplStyle/mplStyle/types/test/test_StyleManager.py/TestStyleManager.testBasic