σ
mάJ]c           @` s   d  d l  m Z m Z m Z m Z d  d l Z e d  d l Z d  d l m Z d  d l	 j
 j j Z d Z d e f d     YZ d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   DocumentuP  
from bokeh.io import curdoc
from bokeh.model import Model
from bokeh.core.properties import Int, Instance

class AnotherModelInTestScript(Model):
    bar = Int(1)

class SomeModelInTestScript(Model):
    foo = Int(2)
    child = Instance(Model)

curdoc().add_root(AnotherModelInTestScript())
curdoc().add_root(SomeModelInTestScript())
t   TestCodeHandlerc           B` sk   e  Z d    Z e j j e j d d d    Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z RS(
   c         C` s]   t    } t j d d d d  } | j |  | j rI t | j   n  | j sY t  d  S(   Nt   sourceu   # This script does nothingt   filenameu   path/to/test_filename(	   R   t   bahct   CodeHandlert   modify_documentt   failedt   RuntimeErrort   errort   rootst   AssertionError(   t   selft   doct   handler(    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_empty_script>   s    		t   reasonu,   this test doesn't have a Python 3 equivalentc         C` s]   t    } t j d d d d  } | j |  | j rI t | j   n  | j sY t  d  S(   NR   u   exec("print \"XXX\"")R   u   path/to/test_filename(	   R   R   R	   R
   R   R   R   R   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_exec_and___future___flagsG   s    		c         C` sh   t    } t j d t d d  } | j |  | j rI t | j   n  t | j	  d k sd t
  d  S(   NR   R   u   path/to/test_filenamei   (   R   R   R	   t   script_adds_two_rootsR
   R   R   R   t   lenR   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_script_adds_rootsQ   s    		c         C` s\   t    } t j d d d d  } | j |  | j d  k	 sC t  d | j k sX t  d  S(   NR   u   This is a syntax errorR   u   path/to/test_filenameu   Invalid syntax(   R   R   R	   R
   R   t   NoneR   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_script_bad_syntaxZ   s
    	c         C` s\   t    } t j d d d d  } | j |  | j d  k	 sC t  d | j k sX t  d  S(   NR   u   raise RuntimeError('nope')R   u   path/to/test_filenameu   nope(   R   R   R	   R
   R   R   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_script_runtime_errorb   s
    	c         C` s\   t    } t j d d d d  } | j |  | j d  k	 sC t  d | j k sX t  d  S(   NR   u:   import sys; raise RuntimeError("path: '%s'" % sys.path[0])R   u   path/to/test_filenameu   path: 'path/to'(   R   R   R	   R
   R   R   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_script_sys_pathj   s
    	c      	   C` sΟ   t    } t j d d d t d   } | j |  | j d  k	 sI t  d | j k s^ t  t    } t j d d d t d  d d d d	 g  } | j |  | j d  k	 sΆ t  d
 | j k sΛ t  d  S(   NR   u5   import sys; raise RuntimeError("argv: %r" % sys.argv)R   u   path/to/test_filenameu   argv: ['test_filename']t   argvi
   i   i   u#   argv: ['test_filename', 10, 20, 30](   R   R   R	   t   strR
   R   R   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_script_argvr   s    		c         C` sl   t    } t j d d d d  } | j s0 t  | j |  | j rX t | j   n  | j sh t  d  S(   NR   u   # This script does nothingR   u   path/to/test_filename(	   R   R   R	   t   safe_to_forkR   R
   R   R   R   (   R   R   R   (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   test_safe_to_fork   s    		(   t   __name__t
   __module__R   t   pytestt   markt   skipift   sixt   PY3R   R   R   R   R   R   R!   (    (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyR   :   s   		$
						(   t
   __future__R    R   R   R   R$   R'   t   bokeh.documentR   t   bokeh.application.handlers.codet   applicationt   handlerst   codeR   R   t   objectR   (    (    (    sI   lib/python2.7/site-packages/bokeh/application/handlers/tests/test_code.pyt   <module>   s   " 	
