# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1351024956 25200
# Node ID d946ca7a4114cbd6b4e0431cbf11f12753dfb1e0
# Parent e669e8774fe13af66d738e8d765b42ea4ad43c8f
Doctest that "%runfile blah" is not preparsed, but "%time blah" is.
diff git a/sage/misc/sage_extension.py b/sage/misc/sage_extension.py
a

b

A Sage extension which adds sagespecifi 
11  11  * running init.sage 
12  12  * changing prompt to Sage prompt 
13  13  * Display hook 
 14  
 15  TESTS: 
 16  
 17  We test that preparsing is off for ``%runfile``, on for ``%time``:: 
 18  
 19  sage: import os, re 
 20  sage: from sage.misc.interpreter import get_test_shell 
 21  sage: from sage.misc.misc import tmp_dir 
 22  sage: shell = get_test_shell() 
 23  sage: TMP = tmp_dir() 
 24  
 25  The temporary directory should have a name of the form 
 26  ``.../12345/...``, to demonstrate that file names are not 
 27  preparsed when calling ``%runfile``. :: 
 28  
 29  sage: bool(re.search('/[09]+/', TMP)) 
 30  True 
 31  sage: tmp = os.path.join(TMP, 'run_cell.py') 
 32  sage: f = open(tmp, 'w'); f.write('a = 2\n'); f.close() 
 33  sage: shell.run_cell('%runfile '+tmp) 
 34  sage: shell.run_cell('a') 
 35  2 
 36  
 37  In contrast, input to the ``%time`` magic command is preparsed:: 
 38  
 39  sage: shell.run_cell('%time 594.factor()') 
 40  CPU times: user ... 
 41  Wall time: ... 
 42  2 * 3^3 * 11 
14  43  """ 
15  44  
16  45  from IPython.core.hooks import TryNext 