<s> from __future__ import absolute_import , print_function <EOL> import unittest <EOL> from bokeh . application . handlers import FunctionHandler <EOL> from bokeh . document import Document <EOL> from bokeh . model import Model <EOL> from bokeh . core . properties import Int , Instance <EOL> class AnotherModelInTestFunction ( Model ) : <EOL> bar = Int ( <NUM_LIT:1> ) <EOL> class SomeModelInTestFunction ( Model ) : <EOL> foo = Int ( <NUM_LIT:2> ) <EOL> child = Instance ( Model ) <EOL> class TestFunctionHandler ( unittest . TestCase ) : <EOL> def test_empty_func ( self ) : <EOL> def noop ( doc ) : <EOL> pass <EOL> handler = FunctionHandler ( noop ) <EOL> doc = Document ( ) <EOL> handler . modify_document ( doc ) <EOL> if handler . failed : <EOL> raise RuntimeError ( handler . error ) <EOL> assert not doc . roots <EOL> def test_func_adds_roots ( self ) : <EOL> def add_roots ( doc ) : <EOL> doc . add_root ( AnotherModelInTestFunction ( ) ) <EOL> doc . add_root ( SomeModelInTestFunction ( ) ) <EOL> handler = FunctionHandler ( add_roots ) <EOL> doc = Document ( ) <EOL> handler . modify_document ( doc ) <EOL> if handler . failed : <EOL> raise RuntimeError ( handler . error ) <EOL> assert len ( doc . roots ) == <NUM_LIT:2> </s>
