#NEWLINE# def test_cache_2( ) : #NEWLINE# #INDENT# from enaml.application import Application #NEWLINE# from enaml.styling import StyleCache #NEWLINE# source = dedent ( "    from enaml.widgets.api import Window, Container, PushButton\n    from enaml.styling import StyleSheet, Style, Setter\n\n    enamldef Sheet(StyleSheet):\n        Style:\n            element = 'PushButton'\n            Setter:\n                field = 'background'\n                value = 'blue'\n\n    enamldef Main(Window):\n        alias button\n        Container:\n            PushButton: button:\n                pass\n\n    def init():\n        return Main(), Sheet()\n\n    " ) #NEWLINE# _clear_cache ( ) #NEWLINE# ( main , sheet ) = compile_source ( source , 'init' ) ( ) #NEWLINE# app = Application . instance ( ) #NEWLINE# if ( app is None ) : #NEWLINE# #INDENT# app = Application ( ) #NEWLINE# #UNINDENT# app . style_sheet = source #NEWLINE# styles = StyleCache . styles ( main . button ) #NEWLINE# assert ( len ( styles ) == 1 ) #NEWLINE# assert ( not _cache_items_empty ( ) ) #NEWLINE# assert ( not _cache_styles_empty ( ) ) #NEWLINE# main . destroy ( ) #NEWLINE# assert _cache_items_empty ( ) #NEWLINE# assert ( not _cache_styles_empty ( ) ) #NEWLINE# sheet . destroy ( ) #NEWLINE# assert _cache_styles_empty ( ) #NEWLINE# assert ( app . style_sheet is None )